BBlu
asked on
VBA For Loop not working
I'm new to VBA and have the attached code. Can someone tell me what i'm doing wrong? I'm trying to fill in cells D1-D10 with the numbers 1 through 10.
Sub AddOne()
Dim n As Integer
Dim RanngeToAdd As Range
n = 1
Set RangeToAdd = ActiveSheet.Range("e1:e10")
For Each Cell In RangeToAdd
ActiveCell.Value = n
n = n + 1
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oh....LOL.
Got it!
Thanks, Chris.
I'm new to VBA, but having fun learning it!
Got it!
Thanks, Chris.
I'm new to VBA, but having fun learning it!
ASKER
Oh....LOL.
Got it!
Thanks, Chris.
I'm new to VBA, but having fun learning it!
Got it!
Thanks, Chris.
I'm new to VBA, but having fun learning it!
We all start sometime so i'm glad to help a little bit
Chris
Chris
SImple enough when you see it ... cell instead of activecell. You aren't actually selecting the cell which is good therefore you need to reference 'cell'
Regards,
chris_bottomley
Open in new window