Jenedge73
asked on
Reference a cell contents and formatting
Is there a way I can reference not only a cells contents but also copy its formatting in at the same time?
Thanks experts
Thanks experts
Can you expand on your goal?
Example
You can use Conditional formatting.
If A3 > 4 then Format B3 Blue and Bold font
Example
You can use Conditional formatting.
If A3 > 4 then Format B3 Blue and Bold font
ASKER
I have two worksheets WS1 is completely formatted and had values
WS2 has no formatting
If WS1!A1 is Red formatted as a date DD-MMM-YY (01-Jan-13)
in WS2!A1 I want to =WS1!A1 and I want WS2!A1 to see a red date 01-Jan-13
Can it be done?
WS2 has no formatting
If WS1!A1 is Red formatted as a date DD-MMM-YY (01-Jan-13)
in WS2!A1 I want to =WS1!A1 and I want WS2!A1 to see a red date 01-Jan-13
Can it be done?
The answer to your question depends on the version of Excel that you are using and how you are setting the font color on WS1.
If you are using regular formatting, the code could be as simple as:
If you are using regular formatting, the code could be as simple as:
Sub RedFont()
With Worksheets("Sheet1").Range("A1")
If .Font.ColorIndex = 3 And IsDate(.Value) Then
.Copy Worksheets("Sheet2").Range("A1")
End If
End With
End Sub
If I need to match the date formatting as well as color, then use:
Sub RedFont()
With Worksheets("Sheet1").Range("A1")
If .Font.ColorIndex = 3 And .NumberFormat = "dd-mm-yy" Then
.Copy Worksheets("Sheet2").Range("A1")
End If
End With
End Sub
ASKER
Im using excel 2013
I don't know what you mean by formatting since I want to replicate the formatting from WS1
Sorry if im not very clear
I don't know what you mean by formatting since I want to replicate the formatting from WS1
Sorry if im not very clear
Conditional formatting can be used to set the color of the date in WS1 cell A1. If so, the code needs to be different. Since you are using Excel 2013, I can use the range.DisplayFormat to trap the format (both font color and number format) as the value of the cell is displayed (i.e. taking into account both regular formatting and conditional formatting).
Sub RedFont()
Dim rg As Range
With Worksheets("Sheet1").Range("A1")
If IsDate(.Value) And .DisplayFormat.Font.ColorIndex = 3 And .DisplayFormat.NumberFormat = "dd-mm-yy" Then
.Copy Worksheets("Sheet2").Range("A1")
End If
End With
End Sub
ASKER
basically what I want to do is replicate exactly what is in WS1 into WS2 using (=). Also, I need it to be dynamic so that WS2 will show any change formatting or otherwise in WS1.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help.
I know this is closed, but can you attach the excel sheets.
I would like to take a look.
I would like to take a look.
Open in new window