I am setting up some VBA to auto send emails but cannot get the range right. I need the range to stop at the last filled row in column B.
I have tried;
For Each cell In ws.Range("B2", Selection.End(xlDown))
For Each cell In ws.Range("B2", ("b" & Cells.Rows.Count).End(xlUp))
The second line doesn't work but the top line selects all cells in column B if there are only one or two emails in column B.
Code below;
Range("B3").Select
Dim objOutlook As Object
Dim objMail As Object
Dim ws As Worksheet
Set objOutlook = CreateObject("Outlook.Application")
Set ws = ActiveSheet
For Each cell In ws.Range("B2", Selection.End(xlDown))
Set objMail = objOutlook.CreateItem(0)
With objMail
.To = cell.Value
I need the range to stop at the last filled row in column B no matter how many rows have data.