Franplante
New Member
- Joined
- Mar 31, 2011
- Messages
- 8
I'm trying to script this macro to end autofill when the variable changes. This is my script so far. I know it is not right. Any help possible would be appreciated.
I want the autofill to end when Field Location changes. It repeats the same value over and over again for multiple rows, which is what I want. When it changes to a new value I want it to stop and not autofill the new value. I am using the index and match function to fill this table with dynamic information to change when a variable changes on another worksheet. As that variable changes I want the table to load only with the data associated with the variable selected.
Sub FieldLocation()
'
' FieldLocation Macro
Dim Lastrow As Long
Lastrow = Range("A2:A" & Rows.Count).End(xlDown).Row
ActiveCell.FormulaR1C1 = _
"=INDEX('Elleh Block'!C:C[5],MATCH(List!R8C12,'Elleh Block'!C[1],0)+ROW()-2,2,1)"
Range("A2").Select
Range("A2").AutoFill Destination:=Range("A2:A" & Lastrow), Type:=xlFillDefault
Range("A2:A" & Lastrow).Select
End Sub
Thank you!
I want the autofill to end when Field Location changes. It repeats the same value over and over again for multiple rows, which is what I want. When it changes to a new value I want it to stop and not autofill the new value. I am using the index and match function to fill this table with dynamic information to change when a variable changes on another worksheet. As that variable changes I want the table to load only with the data associated with the variable selected.
Sub FieldLocation()
'
' FieldLocation Macro
Dim Lastrow As Long
Lastrow = Range("A2:A" & Rows.Count).End(xlDown).Row
ActiveCell.FormulaR1C1 = _
"=INDEX('Elleh Block'!C:C[5],MATCH(List!R8C12,'Elleh Block'!C[1],0)+ROW()-2,2,1)"
Range("A2").Select
Range("A2").AutoFill Destination:=Range("A2:A" & Lastrow), Type:=xlFillDefault
Range("A2:A" & Lastrow).Select
End Sub
Thank you!