Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rich Young
 
Posts: n/a
Default Function for copying color formatting

I am attempting to copy the color formatting from one cell to another on a
different worksheet. I do not see a function for it so I was wondering if
there was some VBA code to do it.

Here is an example of what I am trying to do:

Worksheet A has A1 formatted with red, A2 formatted with yellow, and A3
formatted with green. All which are conditionally formatted.

On worksheet B, I want to reference A1 (or any cell) from worksheet A which
would include the contents and color.

Any help is appreciated!

Rich
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gary''s Student
 
Posts: n/a
Default Function for copying color formatting

This is only partially useful:

Sub format_painter()
Dim r, r2 As Range
Dim s As String
Dim b As Boolean
For Each r In Selection
If r.HasFormula Then
s = r.Formula
s = Right(s, Len(s) - 1)
On Error Resume Next
Set r2 = Range(s)
On Error GoTo 0
b = Not r2 Is Nothing
If b Then
r2.Copy
r.PasteSpecial Paste:=xlPasteFormats
End If
End If
Next
End Sub

If you select a cell that has a direct reference like:
=Sheet2!A3
and run the macro, it will go back to Sheet2, cell A3, copy and format-paste
it to the target. I say partially successful because it can't copy
complicated formats.
--
Gary's Student


"Rich Young" wrote:

I am attempting to copy the color formatting from one cell to another on a
different worksheet. I do not see a function for it so I was wondering if
there was some VBA code to do it.

Here is an example of what I am trying to do:

Worksheet A has A1 formatted with red, A2 formatted with yellow, and A3
formatted with green. All which are conditionally formatted.

On worksheet B, I want to reference A1 (or any cell) from worksheet A which
would include the contents and color.

Any help is appreciated!

Rich

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rich Young
 
Posts: n/a
Default Function for copying color formatting

Thanks Gary, I will give it a try!

"Gary''s Student" wrote:

This is only partially useful:

Sub format_painter()
Dim r, r2 As Range
Dim s As String
Dim b As Boolean
For Each r In Selection
If r.HasFormula Then
s = r.Formula
s = Right(s, Len(s) - 1)
On Error Resume Next
Set r2 = Range(s)
On Error GoTo 0
b = Not r2 Is Nothing
If b Then
r2.Copy
r.PasteSpecial Paste:=xlPasteFormats
End If
End If
Next
End Sub

If you select a cell that has a direct reference like:
=Sheet2!A3
and run the macro, it will go back to Sheet2, cell A3, copy and format-paste
it to the target. I say partially successful because it can't copy
complicated formats.
--
Gary's Student


"Rich Young" wrote:

I am attempting to copy the color formatting from one cell to another on a
different worksheet. I do not see a function for it so I was wondering if
there was some VBA code to do it.

Here is an example of what I am trying to do:

Worksheet A has A1 formatted with red, A2 formatted with yellow, and A3
formatted with green. All which are conditionally formatted.

On worksheet B, I want to reference A1 (or any cell) from worksheet A which
would include the contents and color.

Any help is appreciated!

Rich

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a Custom Excel Function to Calculate Gini Coefficients [email protected] Excel Worksheet Functions 3 February 21st 06 10:15 PM
Date & Time mully New Users to Excel 4 May 23rd 05 11:56 AM
Hyperlinks using R[1]C[1] and offset function in its cell referenc Elijah-Dadda Excel Worksheet Functions 0 March 5th 05 03:31 AM
Conversion SVC Excel Worksheet Functions 9 February 28th 05 02:29 PM
HOW CAN I GET OFFICE 2003 EXCEL BASIC TO NEST FUNCTIONS LIKE EXCE. Robert AS Excel Worksheet Functions 4 December 2nd 04 10:49 AM


All times are GMT +1. The time now is 11:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"