View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Hari Prasadh Hari Prasadh is offline
external usenet poster
 
Posts: 63
Default Cleaning up the syntax

Hi,

I have 2 lines of code Which works perfectly fine

Cells(1, 1) = "=VLookup(" & """" & sheeetname & """" & " , m7:n" & opi & ",
2, False)"
Worksheets("" & Cells(1, 1) & "").Select

Can I somehow reduce them to one line of code by not using cells(1,1) as an
intermediary.

I tried the following variations

a) Worksheets("" & Application.VLookup("""" & sheeetname & """", "m7:n" &
opi, 2, False) & "").Select

b) Worksheets(Application.VLookup("""" & sheeetname & """", "m7:n" & opi,
2, False)).Select

c) Worksheets(Application.VLookup(""" & sheeetname & """, "m7:n" & opi, 2,
False)).Select

But getting Run-time error 13, type mismatch.

Please guide me.

Thanks a lot,
Hari
India