Need Warning To Appear

GA81848

Board Regular
Joined
Apr 25, 2005
Messages
124
I'm using a userform with textbox6 to enter data, however I have a major problem and need some help.

When the user types the date in to textbox6 and it is in the past I need the following to happen:-

1. The background colour to change to red.
2. I also have a label which I need a message to appear saying "Date has passed"

I also have a button on the userform which records the value from the textbox6 into cell G37 of a worksheet called Input. I also need the following to happen:-

3. When the data is being placed into cell G37 and the date is in the past then I need the background colour to turn Red. I've tried using conditional format but this will not work.
4. Finally, when the data is being placed into cell G37 and it's in the past I need cell G38 to be updated with the following "Message Was Displayed".

Sorry about all the questions in one post but I need to get this done quickly and am struggling.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Have almost got what I want but need a bit of help. If cells G37 and G38 have values in them I don't want macro to run. If either cell is empty then I need macro to proceed.

This is the code that I've been working on for my userform:-

With TextBox1
If DateValue(.Text) < Date Then

Sheets("Sheet1").Range("B2").Value = "Yes"
Range("B2").Select
With Selection.Interior
.ColorIndex = 6
End With
Label1 = "Warning - Date Has Passed"
Else
Sheets("Sheet1").Range("B2").Value = "No"
Range("B2").Select
With Selection.Interior
.ColorIndex = 0
End With
Label1 = ""
End If
End With
 
Upvote 0
Am struggling getting the macro to work.

Can anyone advise what I'm doing wrong with this example?

With Worksheets("Sheet1")
If .Range("A2") Is Null And .Range("B4") Is Null Then
MsgBox "No Data"
Else
MsgBox "Data in cells"
End If
End With
 
Upvote 0
Try

Code:
With Worksheets("Sheet1")
    If .Range("A2").Value = "" And .Range("B4").Value = "" Then
        MsgBox "No Data"
    Else
        MsgBox "Data in cells"
    End If
End With
 
Upvote 0

Forum statistics

Threads
1,214,864
Messages
6,121,981
Members
449,058
Latest member
oculus

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