View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Howard Howard is offline
external usenet poster
 
Posts: 536
Default Columns as variable in Vlookup


How do I translate the Long returned by loc_1 and lcol into something the vlookup formula will accept? On my test sheet they are 4 & 5 with current data.

Thanks,
Howard

Option Explicit

Sub Vx_x()

Dim lcol As Long
Dim lcol_1 As Long

lcol_1 = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column - 1
lcol = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column

MsgBox lcol_1 & " " & lcol

Range("G12").Formula = "=vlookup(F12,lcol_1:lcol,2,0)"

End Sub