Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello everyone,
I need a macro that checks to see if a date matches from another spreadsheet. If it does I need the macro to continue running if it doesn't match I need a message box to pop up and ask "is this okay", yes or no. if yes macro continues (I already have the macro written to continue) if no macro stops ie: JMF Targets=Range "B9" ~~~ This is where the date will be input JMF Changes= Range "B500" ~~ this is where the date needs to match Any help would be appreciated. Thank you very much and I hope yo have a great day. Eric |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On 18 Feb, 12:45, Eric wrote:
Hello everyone, I need a macro that checks to see if a date matches from another spreadsheet. *If it does I need the macro to continue running if it doesn't match I need a message box to pop up and ask "is this okay", yes or no. if yes macro continues (I already have the macro written to continue) if no macro stops ie: JMF Targets=Range "B9" *~~~ This is where the date will be input JMF Changes= Range "B500" ~~ this is where the date needs to match Any help would be appreciated. *Thank you very much and I hope yo have a great day. Eric maybe something like: if Range("B9") = Range("B500") then else if msgbox("Is this ok", vbyesno,"Date difference") = vbno then End end if end if |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
WhytheQ's suggestion will work if user interaction is acceptable. Another
option for VBA automation is a simple boolean check to avoid user interaction on comparisons that pass the test of being the same date. The thing to be aware of is that Excel may show only the date but still have a date /and/ time stored. Numerically, dates are integers, and hours/mins/secs are the decimal part of the cell value. So if you want to do your check in code, you need to remove the decimal part of each value to make a date-only comparison. This messagebox also shows the two values in the messagebox so the user doesn't have to manually find them to compare. [Aircode, be sure to dim all your variables and (recommended) use option explicit. Watch for linewrap] d1 = Sheet1.Range("B9").Value \ 1 d2 = Sheet1.Range("B500").Value \ 1 'to make what shows up in your msgbox readable as a date FinalDate1 = CDate(d1) FinalDate2 = CDate(d2) If d1 < d2 then if msgbox ("Is this ok?" & chr(13) & chr(13) & "Date 1: " & FinalDate1 & chr(13) & "Date 2: " & FinalDate2 , vbyesno, "Date Difference") then end end if end if "WhytheQ" wrote in message ... On 18 Feb, 12:45, Eric wrote: Hello everyone, I need a macro that checks to see if a date matches from another spreadsheet. If it does I need the macro to continue running if it doesn't match I need a message box to pop up and ask "is this okay", yes or no. if yes macro continues (I already have the macro written to continue) if no macro stops ie: JMF Targets=Range "B9" ~~~ This is where the date will be input JMF Changes= Range "B500" ~~ this is where the date needs to match Any help would be appreciated. Thank you very much and I hope yo have a great day. Eric maybe something like: if Range("B9") = Range("B500") then else if msgbox("Is this ok", vbyesno,"Date difference") = vbno then End end if end if |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Help me to first row matching First date and last row matching lastrow | Excel Programming | |||
MATCHING DATE TO A WEEKDAY | Excel Worksheet Functions | |||
Sum Rows with a matching date | Excel Discussion (Misc queries) | |||
Matching a Date question | New Users to Excel | |||
Matching Date From Two Groups | Excel Worksheet Functions |