Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default Matching a date or value

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Matching a date or value

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Matching a date or value

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me to first row matching First date and last row matching lastrow [email protected] Excel Programming 3 January 21st 08 04:32 PM
MATCHING DATE TO A WEEKDAY Stuart Carnachan Excel Worksheet Functions 3 October 31st 06 05:19 PM
Sum Rows with a matching date teeb Excel Discussion (Misc queries) 4 April 18th 06 12:49 PM
Matching a Date question ben simpson New Users to Excel 1 March 9th 06 09:12 AM
Matching Date From Two Groups wsteel Excel Worksheet Functions 3 June 25th 05 02:58 AM


All times are GMT +1. The time now is 03:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"