View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
john young john young is offline
external usenet poster
 
Posts: 1
Default Vlookup - column index number - create as variable

I'm writing the following code to fill spreadsheets with
vlookup formulas. I can get the formula to be put in the
rows down & across that I need to fill, but what I want
to be able to do is create a variable so that the
col_index_num in the vlookup changes as the formula is
placed into that colum.

variable = 1 to 10
eg - =vlookup(a1,a5:f10,PUT VARIABLE HERE,0)
next variable

is this possible ????



Sub Macro20()
'
' Macro20 Macro
' Macro recorded 5/08/2004 by John Young
Dim rowcount As Integer
Dim columncount As Integer
Dim cellcountdown As Integer
Dim cellcountacross As Integer

Sheets("g419015_2_lf6_intersect_summari").Activate

Range("a2", Range("a2").End(xlDown)).Select
rowcount = Selection.Rows.Count

Range("g1", Range("g1").End(xlToRight)).Select
columncount = Selection.Columns.Count


For cellcountdown = 2 To (rowcount + 1)

For cellcountacross = 1 To columncount

'Cells(cellcountdown, (cellcountacross +
6)).VALUE = "=VLOOKUP(RC[-
1],'[BHSTStateRegister_TESTJY.xls]Broad Hydrological Soil
Types'!R2C1:R201C63,2,FALSE)"
'Cells(cellcountdown, (cellcountacross +
6)).VALUE = "=VLOOKUP(RC[-
1],'[BHSTStateRegister_TESTJY.xls]Broad Hydrological Soil
Types'!R2C1:R201C63,2,FALSE)"
Cells(cellcountdown, (cellcountacross + 6)).VALUE
= "=VLOOKUP(RC[-1],'[BHSTStateRegister_TESTJY.xls]Broad
Hydrological Soil Types'!R2C1:R201C63,RC[1],FALSE)"

Next cellcountacross

Next cellcountdown



Range("A2").Select
End Sub