Set Read Cell Attributes

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
2,050
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Code:
Dim x As Range
Set x = Worksheets("Sheet1").Range("C2:C5")
Dim cell

For Each cell In x
  Debug.Print cell.Font.Color
  Debug.Print cell.Font.Name
  Debug.Print cell.Interior.Color
Next

Why does Debug.Print cell.Font.Color always return 0 regardless of the actual font color ?

This is giving an error, how might I correct it ?
Worksheets("Sheet1").Range("C2:C5").cell.font.name= "MS Sans Serif"

Thanks
 
Last edited:

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Change to:

Code:
Worksheets("Sheet1").Range("C2:C5").Font.Name = "MS Sans Serif"
 
Upvote 0
Thanks for sorting that.
Anyone know the best plan for reading a cells Fore and Back color, then applying that to another worksheet.
It's proving to be a bit tricky as there's so many methods , all of which I've seen so far are just crazy complicated.
r-Click-FormatCells-Fill-MoreColors-Custom gives the right RGB value, but I can't get that into VBA (even recording a macro)
 
Upvote 0
Do you mean you want to do something like the following to apply the J3 font name to D12 and also apply the size?

Code:
Range("D12").Font.Name = Range("J3").Font.Name
Range("D12").Font.Size = Range("J3").Font.Size
 
Last edited:
Upvote 0
That's sort of it, but they're on 2 diff computers and needs back & foreground colours. That's the bit I'm having trouble with.
 
Upvote 0
I don't know how you'd find the attributes of a workbook on one computer and then apply them to another computer's workbook.

You can find the background color (which is the interior color) or the font color using:

Code:
Range("D12").Interior.Color = Range("J3").Interior.Color
Range("D12").Font.Color = Range("J3").Font.Color
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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