Value Formula in VBA

cartermastro

New Member
Joined
Jul 27, 2018
Messages
20
I am looking for a VBA code that pulls a value from a cell into a email, i already have a code for the email, the only two lines i cant fill are what cells to grab the information from. I would like to place a formula in this spot which pulls information from a cell in column C, how would i write a line that allows me to pull information from column C that has the same y coordinate as my targeted cell.

Sub If_else_using_For()

Dim x As Integer


For x = 4 To 980
If Cells(x, 10).Value = 1 Then
Call Macro2
Cells(x, 11).Value = "ORDER"

ElseIf Cells(x, 10).Value = 2 Then
Cells(x, 11).Value = "Good"

End If

Next x


End Sub


Sub Macro2()
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
Dim WorksheetName As String


Dim x As Integer
Dim PageName As String
Dim AccountName As String
Dim AccountBalance As String
WorksheetName = "Data"
PageName = "Work Area"
AccountName = __________________?
AccountBalance =_________________?








Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)




xMailBody = "Hi there" & vbNewLine & vbNewLine & AccountName & vbNewLine & AccountBalance




On Error Resume Next
With xOutMail
.To = "Email Address"
.CC = ""
.BCC = ""
.Subject = "send by cell value test"
.Body = xMailBody
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Cross posted https://www.excelforum.com/excel-pr...81-vba-code-using-value-or-other-formula.html

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0

Forum statistics

Threads
1,215,374
Messages
6,124,574
Members
449,173
Latest member
Kon123

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