Loop question

MOB

Well-known Member
Joined
Oct 18, 2005
Messages
1,066
Office Version
  1. 365
Platform
  1. Windows
Code:
Range("M8").FormulaR1C1 = "Yes"
Range("M8").FormulaR1C1 = "No"
        
Range("M19").FormulaR1C1 = "Yes"
Range("M19").FormulaR1C1 = "No"
        
Range("M30").FormulaR1C1 = "Yes"
Range("M30").FormulaR1C1 = "No"

Using the above as an example, where the range increments by 11 each time until M1097, what would the syntax be to simplify this as a loop?

I know the code seems to not do much, but entering "Yes" in a cell triggers an automatic system posting, "No" hibernates it.

Thanks
 
Last edited:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Code:
Public Sub SetYesNo()
Dim i As Long

i = 8
While i < 1098
    Range("M" & i).FormulaR1C1 = "Yes"
    Range("M" & i).FormulaR1C1 = "No"
    i = i + 11
Next
End Sub
 
Last edited:
Upvote 0
Or another way

Code:
Sub Step11()
    Dim i As Long
    For i = 8 To 1097 Step 11
        Cells(i, "M").Value = "Yes"
        Cells(i, "M").Value = "No"
    Next
End Sub
 
Upvote 0
Code:
Sub Increment()
Dim i As Long
Application.ScreenUpdating = False
For i = 8 To 1097 Step 11
    With Cells(i, 13)
        .FormulaR1C1 = "Yes"
        .FormulaR1C1 = "No"
    End With
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks all
 
Last edited:
Upvote 0

Forum statistics

Threads
1,226,217
Messages
6,189,687
Members
453,563
Latest member
Aswathimsanil

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