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
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