Macro to add font color and cell color + to add a simple formula in a specific range

hnt007

Board Regular
Joined
Dec 18, 2021
Messages
98
Office Version
  1. 365
Platform
  1. MacOS
Hi! Thank you very much for helping me out with this... I'm trying to have a macro (that I would link to a button called RESET) that will apply a bunch of things to the range D8:D1000:

- adding the formula =L8 in D8, =L9 in D9, =L10 in D10 etc until =L1000 in D1000
- font color > black
- cell color > none
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
How about:

VBA Code:
Sub AddFormulas()
'
    Range("D8").Formula = "=L8"
    Range("D8:D1000").FillDown
    Range("D8:D1000").Font.ThemeColor = xlThemeColorLight1
    Range("D8:D1000").Interior.Pattern = xlNone
End Sub
 
Upvote 0
How about:

VBA Code:
Sub AddFormulas()
'
    Range("D8").Formula = "=L8"
    Range("D8:D1000").FillDown
    Range("D8:D1000").Font.ThemeColor = xlThemeColorLight1
    Range("D8:D1000").Interior.Pattern = xlNone
End Sub
This looks very promising, thank you! Is there a way to add a line to also remove content from B8:B1000?
 
Upvote 0
VBA Code:
Sub AddFormulas()
'
    Range("D8").Formula = "=L8"
    Range("D8:D1000").FillDown
    Range("D8:D1000").Font.ThemeColor = xlThemeColorLight1
    Range("D8:D1000").Interior.Pattern = xlNone
    Range("B8:B1000").ClearContents
End Sub
 
Upvote 0
VBA Code:
Sub AddFormulas()
'
    Range("D8").Formula = "=L8"
    Range("D8:D1000").FillDown
    Range("D8:D1000").Font.ThemeColor = xlThemeColorLight1
    Range("D8:D1000").Interior.Pattern = xlNone
    Range("B8:B1000").ClearContents
End Sub

WOW Johnny this is amazing!! The only problem I have is that it's messing up my borders, see below for before and after running the macro
 

Attachments

  • Screen Shot 2022-05-05 at 3.47.39 PM.png
    Screen Shot 2022-05-05 at 3.47.39 PM.png
    56.8 KB · Views: 7
  • Screen Shot 2022-05-05 at 3.47.06 PM.png
    Screen Shot 2022-05-05 at 3.47.06 PM.png
    31.7 KB · Views: 6
Upvote 0
Which code does that? The first code or the second code?
 
Upvote 0
I don't see how.

But anyways, What type of borders do the cells normally have? Your picture doesn't appear to display a default border, but that could just be the picture.

Can you upload a sample file that we can look at? Then provide the link to it?
 
Upvote 0
I don't see how.

But anyways, What type of borders do the cells normally have? Your picture doesn't appear to display a default border, but that could just be the picture.

Can you upload a sample file that we can look at? Then provide the link to it?

Thanks for you help, here is a copy of my file: !!MDP Rev_May_5_2022.xlsm

So basically you fill out column B with filenames and then press the button CLICK HERE to see if you have misspelled words etc, and if you click on START OVER, everything gets erased which is great, but it messes up the look of that column D

Yeah it's a border that I picked, not a default one...
 
Upvote 0
You fed me some faulty information, but how about:

VBA Code:
Sub Reset()
'
    Range("D8:D1000").FormulaR1C1 = "=RC[8]"
    Range("D8:D1000").Font.ThemeColor = xlThemeColorLight1
    Range("D8:D1000").Interior.Pattern = xlNone
    Range("B8:B1000").ClearContents
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,220
Messages
6,123,698
Members
449,117
Latest member
Aaagu

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