I have a command button with an assigned macro (code listed below) and what I am trying to do is each time I click on the command button I want to 'replace' eleven cells with new data from an array (named cell range) - so I am trying to increment a variable and use it as a counter so every click will advance new data into the appropriate cells. At the moment when I click on the command button I get the following error: "Run-time error'1004': Application-defined or object-defined error"
I have tried different ways of dimensioning the variable using private, Public, Dim and currently Static but I always get this error? I would appreciate any help?
Thanks
Steve
Sub MileChart()
'
' MileChart Macro
Static i As Integer
i = i + 1
' Dim i As Integer
Range("AT3").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[i]C3,FName,1,FALSE)"
Range("AU3").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[i]C1,Array,11,FALSE)"
Range("AV3").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[i]C1,Array2,11,FALSE)"
Range("AW3").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[i]C1,Array3,11,FALSE)"
Range("AX3").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[i]C1,Array4,11,FALSE)"
Range("AY3").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[i]C1,Array5,11,FALSE)"
Range("AZ3").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[i]C1,Array6,11,FALSE)"
Range("BA3").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[i]C1,Array7,11,FALSE)"
Range("BB3").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[i]C1,Array8,11,FALSE)"
Range("BC3").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[i]C1,Array9,11,FALSE)"
Range("BD3").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[i]C1,Array10,11,FALSE)"
Range("BD4").Select
End Sub
Bookmarks