Help with VBA

xPrymaL

New Member
Joined
May 14, 2019
Messages
4
Just trying to create a macro that runs when I open my workbook. I need it to check a date in a column(h) and return a pop up if the date is today or has gone past already.

I then need to check a column in the same workbook(i) to see if there has been another date entered and if there has to not display the first pop up.


I've managed to create the macro to make the pop up appear if the date has gone past, but I cannot get it to check the next column and not display the pop up if I have entered another date.

I've attempted to use an ElseIf statement, but I have probably used it in the wrong way.


I'm new to using VBA so any help would be greatly appreciated


Current Code:

Private Sub Auto_Open()
'Sets cell as Range
Dim cell As Range
'Checks Date in cell and gives pop up on Date past call date
For Each cell In Range("h3, h100")
If IsDate(cell.Value) Then
If cell.Value <= Now() Then
MsgBox "Call Required:" & cbCrLf & cell.Value & "; S/O# " & cell.Offset(0, -7).Value
End If
End If
Next cell
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
For Each cell In Range("h3, h100")
This not should be For Each cell In Range("h3:h100") ??
 
Upvote 0
This assumes there is a date in col I


Code:
Private Sub Auto_Open()
'Sets cell as Range
Dim cell As Range
'Checks Date in cell and gives pop up on Date past call date
For Each cell In Range("H3:H100")
If IsDate(cell.Value) And cell.Value <= Date And Not IsDate(cell.Offset(, 1)) Then
MsgBox "Call Required:" & vbCrLf & cell.Value & "; S/O# " & cell.Offset(, -7).Value
End If
Next cell
End Sub
 
Upvote 0
I don't know if it's what I've got written in my columns, but it doesn't seem to work for me.

I've got dates in column H, and a date in column I, but when the date in column I is set to an earlier date than today it doesn't give me a pop up on opening.

any ideas?
 
Upvote 0
You didn't say EARLIER date in your first post, you said ANOTHER date!!
Try this

Code:
Private Sub Auto_Open()
'Sets cell as Range
Dim cell As Range
'Checks Date in cell and gives pop up on Date past call date
For Each cell In Range("H3:H100")
If IsDate(cell.Value) And cell.Value <= Date And cell.Offset(, 1).Value <= Date Then
MsgBox "Call Required:" & vbCrLf & cell.Value & "; S/O# " & cell.Offset(, -7).Value
End If
Next cell
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,320
Members
449,218
Latest member
Excel Master

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