Just started learning VBA last week, Where has this been all my life!
I've not even scratched the surface yet but have already automated loads of boring jobs which will save me lots of time and frustration in the future...
I've managed to sort most of my queries from searching through the answers in this forum but I'm completly confused with the autofill method and would like some help.
My task is simple, I select a range (always one column wide, number of rows could be anything even the entire column). I want to be able to autofill a formula one cell to the right of any cell in this range which is coloured green.
So far my code looks like
Sub Fillgreens()
Dim c As Range
Set c = Selection
For Each Cell In c
If Cell.Interior.Color = 5287936 Then Cell.AutoFill Destination:=Offset(0, 1)
Next Cell
End Sub
I'm still learning the basics of VBA (i.e I still have to stop and think whenever I read "properties, methods" etc to think what they actually mean) and would appreciate someone telling me why this is failing.
The error is "Autofill method of range class failed" and the selection of code highlighted is
Then Cell.AutoFill Destination:=Cell.Offset(0, 1)
Please don't laugh as I've tried and tested so many different things here that I have no idea what I've created trying to figure out exactly what is wrong!
I've not even scratched the surface yet but have already automated loads of boring jobs which will save me lots of time and frustration in the future...
I've managed to sort most of my queries from searching through the answers in this forum but I'm completly confused with the autofill method and would like some help.
My task is simple, I select a range (always one column wide, number of rows could be anything even the entire column). I want to be able to autofill a formula one cell to the right of any cell in this range which is coloured green.
So far my code looks like
Sub Fillgreens()
Dim c As Range
Set c = Selection
For Each Cell In c
If Cell.Interior.Color = 5287936 Then Cell.AutoFill Destination:=Offset(0, 1)
Next Cell
End Sub
I'm still learning the basics of VBA (i.e I still have to stop and think whenever I read "properties, methods" etc to think what they actually mean) and would appreciate someone telling me why this is failing.
The error is "Autofill method of range class failed" and the selection of code highlighted is
Then Cell.AutoFill Destination:=Cell.Offset(0, 1)
Please don't laugh as I've tried and tested so many different things here that I have no idea what I've created trying to figure out exactly what is wrong!