[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
Dim rng As Range, cell As Range
On Error Resume Next
Set rng = Application.InputBox("Select the range to be populated.", "Select Range!", Type:=8)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "You didn't select any range.", vbExclamation
Application.ScreenUpdating = False
For Each cell In rng
If WorksheetFunction.IsOdd(cell.Row) And WorksheetFunction.IsOdd(cell.Column) Then
cell.Value = "Odd"
ElseIf WorksheetFunction.IsEven(cell.Row) And WorksheetFunction.IsEven(cell.Column) Then
cell.Value = "Even"
Application.ScreenUpdating = True
Open in new window
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!
Dim rng As Range
Dim r As Long
Dim c As Long
Set rng = Range("A1:G10")
For r = 1 To rng.Rows.Count
For c = 1 To rng.Columns.Count
Select Case (r And 1) + (c And 1)
rng.Cells(r, c) = "Odd"
rng.Cells(r, c) = "Even"
I am trying to write a nested “FOR… NEXT” loop
Dim r As Range
Dim ri As Long
Dim ci As Long
Dim rmax As Long
Dim cmax As Long
Set r = Range("A1:W23")
rmax = r.Rows.Count
cmax = r.Columns.Count
For ri = 1 To rmax Step 2
For ci = 1 To cmax Step 2
Cells(ri, ci).Value = "Odd"
If ri + 1 > rmax Or ci + 1 > cmax Then
Cells(ri + 1, ci + 1).Value = "Even"
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.