MsgBox with Dynamic Text

Kinchen

New Member
Joined
Aug 22, 2011
Messages
14
Hi All,

I am fairly new to VBA and for the life of me I cannot figure out how to have variable text show up in a MsgBox. The code I have so far is:

Code:
Dim a As Integer
Dim b As Integer
Dim [COLOR="Red"]strg[/COLOR] As String




strg = Range("C2").Offset(a, 0).Value

For a = 0 To 1500

If Range("J2").Offset(a, 0).Value < Now() Then
    Range("J2").Offset(a, 0).Interior.Color = RGB(192, 224, 255)
End If
If Range("J2").Offset(a, 0).Value > Now() Then
    Range("J2").Offset(a, 0).Interior.Color = RGB(0, 255, 0)
End If
If Range("J2").Offset(a, 0).Value = Date Then
    Range("J2").Offset(a, 0).Interior.Color = RGB(255, 255, 0)
End If
If Range("J2").Offset(a, 0).Value = Date + 1 Then
    Range("J2").Offset(a, 0).Interior.Color = RGB(255, 0, 0)
    MsgBox ("There is a RFQ Due Tomorrrow")
        If Range("K2").Offset(a, 0).Font.Name = "Wingdings" Then
             [COLOR="red"]MsgBox ("Please Note: There is a Formal Document Due Tomorrow For" & "strg")[/COLOR]
        End If
    
End If

Next a
End Sub

Basically what this Macro does is looks at the date in column J and then triggers a different border colors based on the current date. With the date in column J being tomorrow scenario; I am trying to get the MsgBox to pop up with the "Please Note: There is a Formal Document Due Tomorrow For" & then pull the text (company name) from the corresponding row in Column K.
Thanks in Advance :)
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Code:
MsgBox ("Please Note: There is a Formal Document Due Tomorrow For " & [COLOR=Red]strg[/COLOR])

No quotes around strg. Quotes change it from a variable to a literal.

Gary
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

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