Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Using a time value in a macro

In the place of the 30 in the formula below, I need to enter the time value
of 00:30 but the macro errors out as soon as I do this.

ElseIf Cells(1, 13).Value = 30 Then
OptionButton2.Value = Tue


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using a time value in a macro

You migh run into problems. For example from the immediate window:

? activeCell = timeserial(0,30,0)
False
? activeCell.Text
0:30:00

Depending on how your value gets into the cell, it may be exactly 30 minutes
or it could be a fraction of a second off and still show as 30 minutes. you
might try

if Abs(TimeSerial(0,30,0)-Cells(1,13).Value) < TimeSerial(0,0,1) then

You can change the granularity of the difference you are willing to accept.

so back to the immediate window:
? Abs(TimeSerial(0,30,0)-ActiveCell.Value) < TimeSerial(0,0,1)
True

--
Regards,
Tom Ogilvy


"Tim Williams" <saxifrax at pacbell dot net wrote in message
...
Try

ElseIf Cells(1, 13).Value = TimeSerial(0,30,0) Then


Tim

"Patrick Simonds" wrote in message
...
In the place of the 30 in the formula below, I need to enter the time

value
of 00:30 but the macro errors out as soon as I do this.

ElseIf Cells(1, 13).Value = 30 Then
OptionButton2.Value = Tue






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
Macro / function text time to 24hr excel time passed midnight fortotaling hr's Russmaz Excel Worksheet Functions 2 March 6th 09 04:58 AM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Help with Macro to Convert Date/Time to Time Only Bill[_26_] Excel Programming 5 August 25th 04 01:50 PM
excel - macro - automatic initiation of a macro at a pre-specified "system time" arunjoshi[_3_] Excel Programming 3 May 1st 04 09:42 AM


All times are GMT +1. The time now is 12:45 PM.

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"