Add Conditional format to macro

pedro-egoli

Well-known Member
Joined
Apr 25, 2004
Messages
1,217
Office Version
  1. 2016
Platform
  1. Windows
I have the following macro that places date in cell I7.

Code:
Sub currenttime1()
d = Date
Set Displaytime = Sheets(1).Range("i7")
Displaytime.Cells(1, 1) = Str(d)
Columns("i:i").AutoFit
End Sub

If code is run I would like conditional formatting as follows for cell I7.

Font - Bold
Border - Outline
Pattern - Light blue

Cell would remain blank if code is not run.

Thanks

Pedro
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Easiest thing to do is to record a macro whilst you set up the CF then use the code produced. It's what I'd do.
 
Upvote 0
Thanks Weaver.

After I recorded code i named it currenttime1, in the drop down box re Personal.xls, hoping to join the initial macro which has the same name.

I ran the macro and it coloured cell i7 after I manually added date, so that part works.
However, though I thought it would just be a matter of pasting the date macro (initial currenttime1) above new macro I am unable to do so.

The new macro highlights when I click on page and I cannot enter anything.

With a limited knowledge of vba and too many grey hairs to understand all the terminology I am lost.

If someone can advise how to add a recorded macro to an existing one I will delete what I have done and start again.

The existing macro and start of my recorded macro for conditional formatting looks like this
Code:
Sub currenttime1()
d = Date
Set Displaytime = Sheets(1).Range("i7")
Displaytime.Cells(1, 1) = Str(d)
Columns("i:i").AutoFit
End Sub
Sub currenttime1()
'
' Currenttime1 Macro
' Macro recorded 13-08-2011 by Peter
'

I had pasted recorded macro into word so that is where I got above from.

Thanks

Pedro
 
Upvote 0
post all the code - should be doable.

Unless you're expecting the code to actually work in Word, that is.
 
Upvote 0
Thanks Weaver.
That did not work .

So I tried a different tack and changed the date macro part to simply
Code:
    Range("i7") = Date

Put that before the conditional format macro and it worked.

Thanks
Pedro
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,283
Members
452,902
Latest member
Knuddeluff

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