#1   Report Post  
Desperate
 
Posts: n/a
Default "Enter" in Macros

The following macro inputs the current date and time into one cell:

Sub DateAndTime()
With ActiveCell
.Value =3D Now
.NumberFormat =3D "mm/dd/yy h:mm AM/PM"
End With
End Sub

Since the information is input without using the "Enter" key, however, =
my=20
Data Validation formatting doesn't respond to it. (I have the validation =
set up=20
to flash a warning box if the time isn't between 9:00 AM and 5:00 PM.) =
If I=20
click into the cell affter the macro is run and hit "Enter," the =
validation kicks=20
in, but that kind of defeats the point of having validation at all.

How do I rewrite the macro so that it hits "Enter," so to speak, after =
it has=20
run? =20

Thanks and cheers!


  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

I think I'd just build the validation into that routine.

Sub DateAndTime()
if now timeserial(17,0,0) _
or now < timeserial(9,0,0) then
Msgbox "cannot use this macro!
else
With ActiveCell
.Value = Now
.NumberFormat = "mm/dd/yy h:mm AM/PM"
End With
end if
End Sub

Desperate wrote:

The following macro inputs the current date and time into one cell:

Sub DateAndTime()
With ActiveCell
.Value = Now
.NumberFormat = "mm/dd/yy h:mm AM/PM"
End With
End Sub

Since the information is input without using the "Enter" key, however, my
Data Validation formatting doesn't respond to it. (I have the validation set up
to flash a warning box if the time isn't between 9:00 AM and 5:00 PM.) If I
click into the cell affter the macro is run and hit "Enter," the validation kicks
in, but that kind of defeats the point of having validation at all.

How do I rewrite the macro so that it hits "Enter," so to speak, after it has
run?

Thanks and cheers!


--

Dave Peterson
  #3   Report Post  
Desperate
 
Posts: n/a
Default

Hi, Dave--

I'm not sure if perhaps you aborted your post, but I only
get "Message Unavailable" when I click on your response.
Weird! Might I ask you to try reposting? Thanks!
-----Original Message-----
I think I'd just build the validation into that routine.

Sub DateAndTime()
if now timeserial(17,0,0) _
or now < timeserial(9,0,0) then
Msgbox "cannot use this macro!
else
With ActiveCell
.Value = Now
.NumberFormat = "mm/dd/yy h:mm AM/PM"
End With
end if
End Sub

Desperate wrote:

The following macro inputs the current date and time

into one cell:

Sub DateAndTime()
With ActiveCell
.Value = Now
.NumberFormat = "mm/dd/yy h:mm AM/PM"
End With
End Sub

Since the information is input without using

the "Enter" key, however, my
Data Validation formatting doesn't respond to it. (I

have the validation set up
to flash a warning box if the time isn't between 9:00

AM and 5:00 PM.) If I
click into the cell affter the macro is run and

hit "Enter," the validation kicks
in, but that kind of defeats the point of having

validation at all.

How do I rewrite the macro so that it hits "Enter," so

to speak, after it has
run?

Thanks and cheers!


--

Dave Peterson
.

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

It showed up ok for me--in fact, it was part of you response!

But here it is again:

I think I'd just build the validation into that routine.

Sub DateAndTime()
if now timeserial(17,0,0) _
or now < timeserial(9,0,0) then
Msgbox "cannot use this macro!
else
With ActiveCell
.Value = Now
.NumberFormat = "mm/dd/yy h:mm AM/PM"
End With
end if
End Sub



Desperate wrote:

Hi, Dave--

I'm not sure if perhaps you aborted your post, but I only
get "Message Unavailable" when I click on your response.
Weird! Might I ask you to try reposting? Thanks!
-----Original Message-----
I think I'd just build the validation into that routine.

Sub DateAndTime()
if now timeserial(17,0,0) _
or now < timeserial(9,0,0) then
Msgbox "cannot use this macro!
else
With ActiveCell
.Value = Now
.NumberFormat = "mm/dd/yy h:mm AM/PM"
End With
end if
End Sub

Desperate wrote:

The following macro inputs the current date and time

into one cell:

Sub DateAndTime()
With ActiveCell
.Value = Now
.NumberFormat = "mm/dd/yy h:mm AM/PM"
End With
End Sub

Since the information is input without using

the "Enter" key, however, my
Data Validation formatting doesn't respond to it. (I

have the validation set up
to flash a warning box if the time isn't between 9:00

AM and 5:00 PM.) If I
click into the cell affter the macro is run and

hit "Enter," the validation kicks
in, but that kind of defeats the point of having

validation at all.

How do I rewrite the macro so that it hits "Enter," so

to speak, after it has
run?

Thanks and cheers!


--

Dave Peterson
.


--

Dave Peterson
  #5   Report Post  
Desperate
 
Posts: n/a
Default

Thanks, Dave--got it! I'll give it a shot first thing in
the morning. I appreciate your help a lot!
-----Original Message-----
It showed up ok for me--in fact, it was part of you response!

But here it is again:

I think I'd just build the validation into that routine.

Sub DateAndTime()
if now timeserial(17,0,0) _
or now < timeserial(9,0,0) then
Msgbox "cannot use this macro!
else
With ActiveCell
.Value = Now
.NumberFormat = "mm/dd/yy h:mm AM/PM"
End With
end if
End Sub



Desperate wrote:

Hi, Dave--

I'm not sure if perhaps you aborted your post, but I only
get "Message Unavailable" when I click on your response.
Weird! Might I ask you to try reposting? Thanks!
-----Original Message-----
I think I'd just build the validation into that routine.

Sub DateAndTime()
if now timeserial(17,0,0) _
or now < timeserial(9,0,0) then
Msgbox "cannot use this macro!
else
With ActiveCell
.Value = Now
.NumberFormat = "mm/dd/yy h:mm AM/PM"
End With
end if
End Sub

Desperate wrote:

The following macro inputs the current date and time

into one cell:

Sub DateAndTime()
With ActiveCell
.Value = Now
.NumberFormat = "mm/dd/yy h:mm AM/PM"
End With
End Sub

Since the information is input without using

the "Enter" key, however, my
Data Validation formatting doesn't respond to it. (I

have the validation set up
to flash a warning box if the time isn't between 9:00

AM and 5:00 PM.) If I
click into the cell affter the macro is run and

hit "Enter," the validation kicks
in, but that kind of defeats the point of having

validation at all.

How do I rewrite the macro so that it hits "Enter," so

to speak, after it has
run?

Thanks and cheers!

--

Dave Peterson
.


--

Dave Peterson
.

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
enter data on 1 sheet and make it enter on next avail row on 2nd s Nadia Excel Discussion (Misc queries) 27 September 9th 05 03:39 PM
Enabling macros Peter M Excel Discussion (Misc queries) 3 February 7th 05 10:57 PM
sorting with macros Sorting in macros Excel Discussion (Misc queries) 1 February 1st 05 09:02 AM
Transferring toolbars and macros to other computers Darrell Excel Discussion (Misc queries) 1 January 19th 05 12:21 AM
The available macros list in XL; how to suppress filename from showing KR Excel Discussion (Misc queries) 1 January 10th 05 07:20 PM


All times are GMT +1. The time now is 09:28 AM.

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

About Us

"It's about Microsoft Excel"