for each loop

Jefferson2512

Board Regular
Joined
Sep 16, 2019
Messages
53
how to do it in for each loop??

Code:
Private Sub awp()
    Set wks = Sheet9
    If wks.Range("I3").Offset(0, 0).Text = "Yes" Then
    obYes.Value = True
    ElseIf wks.Range("I3").Offset(0, 0).Text = "No" Then
    obNo.Value = True
    ElseIf wks.Range("I3").Offset(0, 0).Text = "N/A" Then
    obNa.Value = True
    End If
    If wks.Range("J3").Offset(0, 0).Text = "Yes" Then
    obYes1.Value = True
    ElseIf wks.Range("J3").Offset(0, 0).Text = "No" Then
    obNo1.Value = True
    ElseIf wks.Range("J3").Offset(0, 0).Text = "N/A" Then
    obNa1.Value = True
    End If
    If wks.Range("K3").Offset(0, 0).Text = "Yes" Then
    obYes2.Value = True
    ElseIf wks.Range("K3").Offset(0, 0).Text = "No" Then
    obNo2.Value = True
    ElseIf wks.Range("K3").Offset(0, 0).Text = "N/A" Then
    obNa2.Value = True
    End If
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Not sure as it worked for me :confused:

Ensure what the strMyCtrl is returning is an actual control name on the form.
 
Upvote 0
If there's a cell formula error like #N/A the code will return this error.
 
Upvote 0
Cross posted https://www.excelforum.com/excel-programming-vba-macros/1290959-for-each-loop.html

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
Thanks Fluff. So annoying when people do that.

I'm out of this thread now.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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