vlookup in visual basic

  • Thread starter Thread starter Rebecca
  • Start date Start date
R

Rebecca

could someone tell me the correct syntax for using vlookup
in visual basic
 
could someone tell me the correct syntax for using vlookup
in visual basic

VLOOKUP is an Excel worksheet function. I've never heard of it existing in
VB. Could you provide more details on what you're trying to do?
 
It says in the help that vlookup can be used in visual
basic, what I am actually doing is in the spreadsheet
looking to the top of the column reading C2 then going to
another spreadsheet and finding that value and giving the
value in the col next to it, as vlookup does in excel.
Then if it is the same a macro starts which deletes the
original row and moves the rest of the table along. I
tried to do it in excel but once the macro has run the
cell reference for C2 is lost, so I thought I could try it
in a macro. Any ideas?
 
It says in the help that vlookup can be used in visual
basic,

"The help"? The help for Excel? If that is what you mean, then it's
referring to the fact that you can access this function (and any worksheet
function) from VBA. If you are indeed writing in VBA (i.e., creating a macro
from within Excel itself) then you'd be much better served by asking in the
proper group. I recommend microsoft.public.excel.programming.
 
Rebecca,

You can use just about any Excel function in VB. You must first include the
Microsoft Excel 9.0 Object Library reference in your application.

Assuming you already created an Excel object and have a reference to a
particular sheet, the syntax for VLookup is

sFound = Application.Worksheetfunction.VLookup(sWhatToLookFor,
WorksheetIdentification.Worksheets("sheetName" or #).Range(Range to look in)

Any of the Worksheet functions are available through the Worksheetfunction.

the WorksheetIdentification is the variable you assigned to the worksheet
you are working on.

Hope this helps

Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top