Dreamteam
New Member
- Joined
- Feb 22, 2018
- Messages
- 28
- Office Version
- 365
- Platform
- Windows
Hi guys,
I am having an issue with the below code. I am guessing that this is rookie mistake but that said I have been trying for a day now with no avail. I am simply trying to use gmail to send various employees worksheets based on their employee code (eg, 1,3,4) and the data is in worksheets named the same way. Sending the mail is no problem but the code is reading the worksheets as an index and therefore sending the wrong ones. Any help would be much appreciated as it is driving me mad... A sample is below...
For Each rngstartcell In rngstartcellcolumn
Set rng = Worksheets(rngstartcell).Range("a1")
Set rng = rng.CurrentRegion
driveremail = rngstartcell.Offset(0, -2)
drivertotal = rngstartcell.Offset(0, 1)
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
With iMsg
Set .Configuration = iConf
.to = driveremail
.CC = ""
.BCC = ""
.From = """*****"" <*******@gmail.com>"
.Subject = "May Acc Work" & drivertotal
.HTMLBody = RangetoHTML(rng)
.Send
End With
Next rngstartcell
I am having an issue with the below code. I am guessing that this is rookie mistake but that said I have been trying for a day now with no avail. I am simply trying to use gmail to send various employees worksheets based on their employee code (eg, 1,3,4) and the data is in worksheets named the same way. Sending the mail is no problem but the code is reading the worksheets as an index and therefore sending the wrong ones. Any help would be much appreciated as it is driving me mad... A sample is below...
For Each rngstartcell In rngstartcellcolumn
Set rng = Worksheets(rngstartcell).Range("a1")
Set rng = rng.CurrentRegion
driveremail = rngstartcell.Offset(0, -2)
drivertotal = rngstartcell.Offset(0, 1)
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
With iMsg
Set .Configuration = iConf
.to = driveremail
.CC = ""
.BCC = ""
.From = """*****"" <*******@gmail.com>"
.Subject = "May Acc Work" & drivertotal
.HTMLBody = RangetoHTML(rng)
.Send
End With
Next rngstartcell