Selecting Data to be emailed in VBA code based on cell color

mrfy6

New Member
Joined
Jul 9, 2019
Messages
2
Please forgive not asking the right questions, but I have created a basic inventory form that I have triggered to email be based on a cell color being = to 255(red). I have column (A) conditionally formatted to fill red when the Inventory(D) drops below the Reorder point(C). As each line item has a different reorder point, I would like to run this as a range and add the material number(A) to the body of the email based on this being red. Below is what I have thus far, which works for 1 of the cells, but how do I modify to select whichever cell may be red instead of copying and pasting this macro for each line item?

Thank you in advance!

Matt

Rich (BB code):
Sub low_inventory()


If Range("A:A").Columns(1).Interior.Color = 255 Then


Call Mail_small_Text_Outlook
End If


End Sub
Sub Mail_small_Text_Outlook()
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
'Working in Office 2000-2016
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String


    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)


    strbody = "Inventory Is low on Material Number: " & Worksheets("TAG_INV").Range("A:A").Columns(1).Interior.Color = 255


    On Error Resume Next
    With OutMail
        .To = "john.doe@abccompany.com"
        .CC = ""
        .BCC = ""
        .Subject = "Low Inventory"
        .Body = strbody
        'You can add a file like this
        '.Attachments.Add ("C:\test.txt")
        .Send   'or use .Display
    End With
    On Error GoTo 0


    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub
 
Last edited by a moderator:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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