Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim row As Range
Dim cell As Range
myvar = "A1:A" & ThisWorkbook.Sheets("Sheet3").Range("A5") - ThisWorkbook.Sheets("Sheet3").Range("A3")
For Each row In Range(myvar).Rows
For Each cell In row.Cells
cell = 1
Next cell
Next row
End Sub
I can't work out what I've done wrong... sometimes I get an error wiht the myvar line.. other times it runs fine but breaks excel.
all it's trying to do is insert 1 in 94 rows. (ThisWorkbook.Sheets("Sheet3").Range("A5") - ThisWorkbook.Sheets("Sheet3").Range("A3") = 94)
Dim rng As Range
Dim row As Range
Dim cell As Range
myvar = "A1:A" & ThisWorkbook.Sheets("Sheet3").Range("A5") - ThisWorkbook.Sheets("Sheet3").Range("A3")
For Each row In Range(myvar).Rows
For Each cell In row.Cells
cell = 1
Next cell
Next row
End Sub
I can't work out what I've done wrong... sometimes I get an error wiht the myvar line.. other times it runs fine but breaks excel.
all it's trying to do is insert 1 in 94 rows. (ThisWorkbook.Sheets("Sheet3").Range("A5") - ThisWorkbook.Sheets("Sheet3").Range("A3") = 94)