troubleshooting Question

VBA For Loop not working

Avatar of BBlu
BBluFlag for United States of America asked on
Microsoft ExcelSQL
5 Comments1 Solution441 ViewsLast Modified:
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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros