What are the available ways to create Nested Loops in VBA?

excelos

Well-known Member
Joined
Sep 25, 2011
Messages
591
Office Version
  1. 365
Platform
  1. Windows
Hello

I want to create this nested loop:

For Each cell In Range("a1:a10")
Cell.value = 1*(For i = 0 to 10 next i)
Next cell

Any idea how it could be structured?

Also are there any other forms/types of nested Loops and what are the possible structures?

Thanks!
 
Thanks, where can I find the documentation for the Cells(i, 1).Value please? Particularly the Cells(i, 1).
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Just search the net for "Cells(i, 1).Value", plenty of sites come up. ;)
 
Upvote 0
I actually think it is mentioned in: Cell Object

By the way, I think:
Cells(i, 1).Value = (i + 4)*100
should be:
Cell(i, 1).Value = (i + 4)*100

Do you agree?
 
Upvote 0
Why are you linking to documentation for Word?
 
Upvote 0
Try the 2 codes below in Excel (see fluff's previous post), and tell us what happens
Documentation link

VBA Code:
Sub FillSequence()
  Dim i As Long

  For i = 1 To 10
    Cell(i, 1).Value = (i + 4) * 100
  Next i
End Sub

VBA Code:
Sub FillSequence()
  Dim i As Long

  For i = 1 To 10
    Cells(i, 1).Value = (i + 4) * 100
  Next i
End Sub
 
Upvote 0
And then, of course, you don't always need a loop :devilish:...
VBA Code:
Sub FillSequence()
  [A1:A10] = [100*ROW(5:14)]
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,823
Messages
6,121,779
Members
449,049
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top