Need to edge out the competition for your dream job? Train for certifications today.
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.
Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy 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.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment