If Active cell = ASKWH and cell same row but offset 2 columns = Depots listed

Eric Penfold

Active Member
Joined
Nov 19, 2021
Messages
424
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
If the above correct then I need the Email Address to change to relevant Email Address?

VBA Code:
Sub Mail_small_Text_Outlook()

    Dim xOutApp As Object
    Dim xOutMail As Object
    Dim xMailBody As String
    Dim ws     As Worksheet
    Dim Rng    As Range
    Dim LRow   As Long
    Dim Cell   As Range
    Dim x      As String
    Dim Found  As Boolean
    Dim EmailAddress As String
    Dim WsConfig As Worksheet
    Dim lngStartRow As Long

    Set xOutApp = CreateObject("Outlook.Application")
    Set xOutMail = xOutApp.CreateItem(0)
    Set ws = ThisWorkbook.Worksheets("Data")
    Set WsConfig = ThisWorkbook.Worksheets("Config")
    LRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
    lngStartRow = WsConfig.Range("B1") + 1
  
    x = "ASKWH"
  
    ws.Range("J" & lngStartRow).Select
    If ActiveCell.Offset(1, 0) = x Then
        Found = True
            If Found = True Then
                If ActiveCell = x & ActiveCell.Offset(1, 2) = "A" Then
                    EmailAddress = ("alton@Drainfast.co.uk")
                ElseIf ActiveCell = x & ActiveCell.Offset(1, 2) = "B" Then
                    EmailAddress = ("warehousebas@Drainfast.co.uk")
                ElseIf ActiveCell = x & ActiveCell.Offset(1, 2) = "C" Then
                    EmailAddress = ("warehousecov@Drainfast.co.uk")
                End If
                End If
                End If
              
                xMailBody = "Hi" & vbNewLine & vbNewLine & _
                            "Do you know why this is a back order? Intact is showing you have the stock?" & vbNewLine & _
                            "" & vbNewLine & _
                            " Kind Regards"
                On Error Resume Next
                With xOutMail
                    .To = "Email Address"
                    .CC = ""
                    .BCC = ""
                    .Subject = "BO Queries"
                    .Body = xMailBody
                    .Display
                End With
                On Error GoTo 0
                Set xOutMail = Nothing
                Set xOutApp = Nothing
End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,215,077
Messages
6,122,992
Members
449,094
Latest member
masterms

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