VBA Time change

Status
Not open for further replies.

BOGIA

Active Member
Joined
May 23, 2005
Messages
266
Hi everyone,

I'm trying to write a short statement to change the time if it is greater than 6:00:00 but it doesn't work. The data I have always 6:00:10 or more.

I have tried this but no good:

If range("a1","a4:a6","a7","a10:a15") > 6:00:00 then
range("a1","a4:a6","a7","a10:a15") = 6:00:00
End if

Could anyone please help! Thanks

TD
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi there

Try this in a standard module:

Sub ResetTime()
For Each cell In Range("a1, a4:a6, a7, a10:a15")
If cell.Value > TimeValue("6:00:00") Then cell.Value = TimeValue("6:00:00")
Next
End Sub


regards
Derek

PS Didn't realise you had 2 threads going with the same question. Best to stick to the original thread or it gets confusing for everyone.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,651
Messages
6,120,739
Members
448,989
Latest member
mariah3

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