Vba code to extract data from cell

dwarek

Board Regular
Joined
Jul 15, 2016
Messages
79
Hello everyone i have assigned a task in the office , i already know the vba code to send mail via outlook and i knew everything is predefined inside the vba code (TO,CC,BCC ,SUBJECT and and BODY).but the issue now is i need to create a userform with combox and extract the value selected in combobox for TO,CC,BCC, SUBJECT and BODY then pass those values into the outlook when i click on a command button..please help me out
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Once you create the userform you would have named each combo then you refer to the combo name something along the lines of

.To = cboTo.Text
.CC = cboCC.Text
.BCC = cboBCC.Text

I am assuming you have already created the VBA code to connect to Outlook.
 
Upvote 0
yes i have already created the vba code just have to do as you advised i will work on it and give you a reply
 
Upvote 0
i have encountered a problem with compile error expected end sub for following code
Private Sub CommandButton1_Click()
Sub SendWorkBook()
Dim OutlookApp As Object
Dim OutlookMail As Object
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
On Error Resume Next
With OutlookMail
.To = ComboBox1.Text
.CC = ""
.BCC = ""
.Subject = ComboBox2.Text
.Body = "ComboBox3.Text"
.Attachments.Add (ActiveWorkbook.FullName)
.Display
End With
Set OutlookMail = Nothing
Set OutlookApp = Nothing
End Sub
End Sub

pls help me out
 
Upvote 0
Happy to help and thank you for letting me know it works.
 
Upvote 0
hi i have to do one more thing to do it is to read the first row and next and next , for example in A2 ,A3....... so on there are list of email recipient to be added to the field (TO of Outlook) and B2,B3... C1,C2.... so on there are text to be added to the field (BODY of the outlook) . so i need to program like read first row then extract data from A2 and pass it TO OF OUTLOOK and then Extract from B2,C2 and pass to BODY OF OUTLOOK then move to next row like A3,B3,C3 then A4,B4,C4 ....... and so on any idea how can program this
 
Upvote 0

Forum statistics

Threads
1,215,731
Messages
6,126,535
Members
449,316
Latest member
sravya

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