Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Copying Cell Formats

Looking for VBA coding to copy just the fill color and font format from one
cell into another. I tried using the macro recorder and the Copy Format
button (the paint brush), but that copies the borders and everything. The
resulting code was:

Range("N27:Q53").Select
Selection.Copy
Range("O27").Select
ActiveSheet.PasteSpecial Format:=4, Link:=1, DisplayAsIcon:=False, _
IconFileName:=False

I assume the ".PasteSpecial Format:=4" part means to paste all formats. I
want just the fill color and font characteristics. Would appreciate any
help. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Copying Cell Formats

Hi Mark
AFAIK this is not possible using the PasteSpecial method (in your case
'Format' specifies the 'clipboard' format which should be used - for more
see the VBA help)

"Mark Schreiber" wrote:

Looking for VBA coding to copy just the fill color and font format from one
cell into another. I tried using the macro recorder and the Copy Format
button (the paint brush), but that copies the borders and everything. The
resulting code was:

Range("N27:Q53").Select
Selection.Copy
Range("O27").Select
ActiveSheet.PasteSpecial Format:=4, Link:=1, DisplayAsIcon:=False, _
IconFileName:=False

I assume the ".PasteSpecial Format:=4" part means to paste all formats. I
want just the fill color and font characteristics. Would appreciate any
help. Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Copying Cell Formats

Hi, Frank.
Thanks for the quick response. Looks like that path does not lead to
success. A possible alternative approach: Is there a way to use VBA to look
at a particular cell and "read" its formatting? For example, the following
code snippet would paint cell D7 red:
Range("D7").Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With

So is there a VBA method to go to cell D7, have it "read" the formatting to
see that its ColorIndex value is 3, store that value in a variable, then
carry that value into another section of code that will insert the variable
value "3" into the ColorIndex property of another cell, say into E7?

Mark

"Frank Kabel" wrote:

Hi Mark
AFAIK this is not possible using the PasteSpecial method (in your case
'Format' specifies the 'clipboard' format which should be used - for more
see the VBA help)

"Mark Schreiber" wrote:

Looking for VBA coding to copy just the fill color and font format from one
cell into another. I tried using the macro recorder and the Copy Format
button (the paint brush), but that copies the borders and everything. The
resulting code was:

Range("N27:Q53").Select
Selection.Copy
Range("O27").Select
ActiveSheet.PasteSpecial Format:=4, Link:=1, DisplayAsIcon:=False, _
IconFileName:=False

I assume the ".PasteSpecial Format:=4" part means to paste all formats. I
want just the fill color and font characteristics. Would appreciate any
help. Thanks.

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
Copying formats - column widths, formats, outlining to worksheets DavidBr318 Excel Worksheet Functions 4 August 14th 09 05:03 AM
Copying Formats JoeSpareBedroom Excel Discussion (Misc queries) 9 February 7th 07 06:33 PM
copying conditional formats Steiner Excel Worksheet Functions 7 August 11th 06 08:14 PM
Copying cell formats Stu - Wast Excel Worksheet Functions 5 August 10th 05 06:20 PM
Prevent formats from copying Weirdism Excel Discussion (Misc queries) 1 June 22nd 05 12:35 PM


All times are GMT +1. The time now is 05:54 AM.

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

About Us

"It's about Microsoft Excel"