VBA For each Loop - select dropdown and call another macro

Melimob

Active Member
Joined
Oct 16, 2011
Messages
395
Office Version
  1. 365
Hi there,

I have the below code which *should* select a dropdown for all in list and call another macro (which creates a PDF and email) but it keeps staying on the same selection producing 20 emails for the one customer?

Any ideas on what I am doing wrong?

VBA Code:
Sub All_Intro_emailPDFLoop()
    Dim c As Range
    Dim Rng As Range
    Set Rng = Range("nDataVal_Introducers_Act_COMBO")
    For Each c In Rng
        Range("G6").Select
        Call emailsavePDF_Intro
    Next
End Sub
 
THANK YOU THANK YOU THANK YOU!

That worked however as some of the clients don't have any data to report, 'the item cannot be found in the OLAP cube' error comes up. I feel I need to include an 'On Error Resume Next' but unsure where to place this line?
Also, I only want the report to run on the clients which are active. There is a cell which returns 'Active'/'Inactive' when the dropdown changes via a lookup however I tried to add this but got an error?:

VBA Code:
Private Sub CommandButton1_Click()

   Dim rep As Long
 
    With Sheet21.ComboBox1
      For rep = 0 To .ListCount - 1
           .Value = .List(rep)
        If .Range("S1").Value = "Active" Then
          Call emailsavePDF_Intro
       End If
     
    On Error Resume Next
     
      Next rep
       
       
   End With
End Sub
ok thanks so much for your help!
 
Upvote 0

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,214,987
Messages
6,122,614
Members
449,091
Latest member
gaurav_7829

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