Excel Loop question

leong82

New Member
Joined
Jan 4, 2018
Messages
4
Hi everyone,

I need help on a code that I writing. Basically the excel worksheet has 2 tabs. Tab 1 is called Client List and the tab 2 is called Email.
The code will go to “Client List”, copy from A2 and past the data into A4 in the tab “Email”. It will then run the macro Email_eDealer.
However, I need this to loop and after completing the macro, it goes to “Client List” again and copy A3 (1 line below A2), past the data into A4 in the tab “Email”. It will then run the macro Email_eDealer. From A3 it will go to A4, then A5 so on and so forth until it reaches a blank cell.

Here is the code without the loop function

Sub Macro2()
'
' Macro2 Macro
'
'
Sheets("Client List").Select
Range("A2").Select
Selection.Copy
Sheets("Email").Select
Range("A4").Select
ActiveSheet.Paste

Call Email_eDealer

End sub

Any help would be great. I roughly know I need a loop function but I am just so new at this. Thanks everyone.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi, welcome to the board!

You could try something like this..

Code:
Sub Macro2()
Dim i As Long
For i = 2 To Sheets("Client List").Range("A" & Sheets("Client List").Rows.Count).End(xlUp).Row
  Sheets("Client List").Range("A" & i).Copy Destination:=Sheets("Email").Range("A4")
  Call Email_eDealer
Next i
End Sub
 
Upvote 0
Hi, welcome to the board!

You could try something like this..

Code:
Sub Macro2()
Dim i As Long
For i = 2 To Sheets("Client List").Range("A" & Sheets("Client List").Rows.Count).End(xlUp).Row
  Sheets("Client List").Range("A" & i).Copy Destination:=Sheets("Email").Range("A4")
  Call Email_eDealer
Next i
End Sub

Yes it works! :) thank you very much for your help!
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,543
Members
449,089
Latest member
davidcom

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