Excel VBA code to automatically change shape colour based on time.

afzal_u1

New Member
Joined
Nov 28, 2013
Messages
6
Hi,

I have working on pretty much the same problem here but with some changes.

I am total new to excel vba and I am working on a project in which in which I have to change the shape colour based on the time of the day for example if it is midnight the shape color should be yellow and if it is 6 O'Clock in the morning the shape colour should be green etc.

The number of shape that I have to work with are about 14 and I have been trying my level best to figure out how to put the time interval in the vba code so that it should work but to not avail.

I looked into attaching the excel sheet with my thread but there was no option so I am adding a part of the code that I want to make changes to currently the shape colour change but not with respect to time but I want to merge the time into the if loop so that time can control the colour of the shapes while other will only display what is the value of the shape.

This is some part of the code I want to merge time with.
[ If ss1 = 582693 Or ss2 = 582693 Or ss3 = 582693 Or ss4 = 582693 Or ss5 = 582693 Or ss6 = 582693 Or ss7 = 582693 Or ss8 = 582693 Then

's/s 582693
ActiveSheet.Shapes.Range(Array("Oval 19")).Select
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0.5
.Solid
End With

Else
's/s 582693
ActiveSheet.Shapes.Range(Array("Oval 19")).Select
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 255, 0)
.Transparency = 0.8
.Solid
End With

End If ]


If anyone can help me with this i would appreciate it a lot.

Thank you, <!-- END TEMPLATE: newreply_reviewbit -->
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
So your asking: I would like a automated colour change on a spreadsheet using realtime? >_<
 
Upvote 0
Well long story short yes its pretty much what you said

But I dont want it to be synchronised with my computer clock but a separate column in the excel sheet in which I have defined time with half an hour interval for the whole day.

Hope this helps you to understand my question
 
Upvote 0
well i can do like: you have a inputbox asking what time it is , you add the time then it will start with the colour that i have set for the time then it will continue on the ticks that have started at the time you had entered and idk if u want it to loop. If you want it to loop reply back. It might take a few hours to code it because this seems like a somewhat a project. When is this due?
 
Upvote 0
Well I want it to loop but can you tell a bit more in details about the inputbox option that you mentioned. yea it is project and is due in next week but i have presentation tomorrow to show my progress with the project.
 
Upvote 0
Alright well i will see if i can do it, If not then i will try to get a friend to help you, Hes better then me :P
 
Upvote 0
Well with the inputbox, You can set the current time or anytime you would like and it would set the colour. With that time, it will start at the ticks at the time you added into the inputbox and it will loop. Thing is, if you turn off your computer then the code wouldn't be running and there wouldn't really be a point in looping the code but if u want to do that then i have no issue with that :)
 
Upvote 0
Do you know how I can attach my excel workbook with this thread. I believe it will help you with coding.
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,816
Members
449,049
Latest member
cybersurfer5000

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