PC Review


Reply
Thread Tools Rate Thread

Copy basic format from one cell to another

 
 
joeeng
Guest
Posts: n/a
 
      4th Jun 2009
Is there a way to copy the basic cell format from one cell to another without
copying the conditional format with it?
 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      4th Jun 2009
Just remove them after the paste:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 6/4/2009 by James Ravenswood
'

'
Range("A1").Select
Selection.Copy
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteFormats
Selection.FormatConditions.Delete
End Sub

--
Gary''s Student - gsnu200856


"joeeng" wrote:

> Is there a way to copy the basic cell format from one cell to another without
> copying the conditional format with it?

 
Reply With Quote
 
joeeng
Guest
Posts: n/a
 
      4th Jun 2009
Thanks for your response. However, I didn't ask that question quite right.
What I really was trying to ask was, is there a way of copying a basic cell
format to another cell without overwriting the conditional format in the
destination cell?

"Gary''s Student" wrote:

> Just remove them after the paste:
>
> Sub Macro1()
> '
> ' Macro1 Macro
> ' Macro recorded 6/4/2009 by James Ravenswood
> '
>
> '
> Range("A1").Select
> Selection.Copy
> Range("A2").Select
> Selection.PasteSpecial Paste:=xlPasteFormats
> Selection.FormatConditions.Delete
> End Sub
>
> --
> Gary''s Student - gsnu200856
>
>
> "joeeng" wrote:
>
> > Is there a way to copy the basic cell format from one cell to another without
> > copying the conditional format with it?

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      4th Jun 2009
If you know what basic cell formats you want you can just apply them:

dim fCell as range
dim tCell as range

set fcell = worksheets("Sheet1").range("a1")
set tcell = worksheets("sheet99").range("x99")

with tcell
.numberformat = fcell.numberformat
'add as many formatting characteristics as you want.
end with

joeeng wrote:
>
> Thanks for your response. However, I didn't ask that question quite right.
> What I really was trying to ask was, is there a way of copying a basic cell
> format to another cell without overwriting the conditional format in the
> destination cell?
>
> "Gary''s Student" wrote:
>
> > Just remove them after the paste:
> >
> > Sub Macro1()
> > '
> > ' Macro1 Macro
> > ' Macro recorded 6/4/2009 by James Ravenswood
> > '
> >
> > '
> > Range("A1").Select
> > Selection.Copy
> > Range("A2").Select
> > Selection.PasteSpecial Paste:=xlPasteFormats
> > Selection.FormatConditions.Delete
> > End Sub
> >
> > --
> > Gary''s Student - gsnu200856
> >
> >
> > "joeeng" wrote:
> >
> > > Is there a way to copy the basic cell format from one cell to another without
> > > copying the conditional format with it?


--

Dave Peterson
 
Reply With Quote
 
joeeng
Guest
Posts: n/a
 
      4th Jun 2009
Understand, but what if one is trying to copy a range of cells with varying
formats (interior colors). Can it be done without using a slow for-next loop?

I tried

worksheets("Sheet1").range("A1:B99").interior.colorindex=worksheets("sheet99").range("A1:B99").interior.colorindex

but this apparently does not work.

"Dave Peterson" wrote:

> If you know what basic cell formats you want you can just apply them:
>
> dim fCell as range
> dim tCell as range
>
> set fcell = worksheets("Sheet1").range("a1")
> set tcell = worksheets("sheet99").range("x99")
>
> with tcell
> .numberformat = fcell.numberformat
> 'add as many formatting characteristics as you want.
> end with
>
> joeeng wrote:
> >
> > Thanks for your response. However, I didn't ask that question quite right.
> > What I really was trying to ask was, is there a way of copying a basic cell
> > format to another cell without overwriting the conditional format in the
> > destination cell?
> >
> > "Gary''s Student" wrote:
> >
> > > Just remove them after the paste:
> > >
> > > Sub Macro1()
> > > '
> > > ' Macro1 Macro
> > > ' Macro recorded 6/4/2009 by James Ravenswood
> > > '
> > >
> > > '
> > > Range("A1").Select
> > > Selection.Copy
> > > Range("A2").Select
> > > Selection.PasteSpecial Paste:=xlPasteFormats
> > > Selection.FormatConditions.Delete
> > > End Sub
> > >
> > > --
> > > Gary''s Student - gsnu200856
> > >
> > >
> > > "joeeng" wrote:
> > >
> > > > Is there a way to copy the basic cell format from one cell to another without
> > > > copying the conditional format with it?

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      4th Jun 2009
If the colors vary between cells, you'll need to loop. If you know your
workbook, maybe you can group areas by color????

And if the colors vary between characters in the cell, then you'll be looping
through each cell and then looping between characters within each cell. (It can
be very slow if you have lots of colors/formats to preserve.)

joeeng wrote:
>
> Understand, but what if one is trying to copy a range of cells with varying
> formats (interior colors). Can it be done without using a slow for-next loop?
>
> I tried
>
> worksheets("Sheet1").range("A1:B99").interior.colorindex=worksheets("sheet99").range("A1:B99").interior.colorindex
>
> but this apparently does not work.
>
> "Dave Peterson" wrote:
>
> > If you know what basic cell formats you want you can just apply them:
> >
> > dim fCell as range
> > dim tCell as range
> >
> > set fcell = worksheets("Sheet1").range("a1")
> > set tcell = worksheets("sheet99").range("x99")
> >
> > with tcell
> > .numberformat = fcell.numberformat
> > 'add as many formatting characteristics as you want.
> > end with
> >
> > joeeng wrote:
> > >
> > > Thanks for your response. However, I didn't ask that question quite right.
> > > What I really was trying to ask was, is there a way of copying a basic cell
> > > format to another cell without overwriting the conditional format in the
> > > destination cell?
> > >
> > > "Gary''s Student" wrote:
> > >
> > > > Just remove them after the paste:
> > > >
> > > > Sub Macro1()
> > > > '
> > > > ' Macro1 Macro
> > > > ' Macro recorded 6/4/2009 by James Ravenswood
> > > > '
> > > >
> > > > '
> > > > Range("A1").Select
> > > > Selection.Copy
> > > > Range("A2").Select
> > > > Selection.PasteSpecial Paste:=xlPasteFormats
> > > > Selection.FormatConditions.Delete
> > > > End Sub
> > > >
> > > > --
> > > > Gary''s Student - gsnu200856
> > > >
> > > >
> > > > "joeeng" wrote:
> > > >
> > > > > Is there a way to copy the basic cell format from one cell to another without
> > > > > copying the conditional format with it?

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic Cell / Formula Copy Using a Step =?Utf-8?B?UmFqZW5SYWpwdXQx?= Microsoft Excel Misc 2 20th Apr 2007 04:44 PM
A visual basic value copy BUG?? - accounting format has copy problem!! yunyanl@gmail.com Microsoft Excel Programming 3 20th Jun 2006 04:42 PM
Lock Cell Format - Allow copy and paste of data without format change Chris12InKC Microsoft Excel Worksheet Functions 1 11th Mar 2006 04:44 AM
How do I copy data in single cell format to a merged cell format =?Utf-8?B?UGF1bA==?= Microsoft Excel Misc 1 27th Jun 2005 11:00 AM
Copy cell format to cell on another worksht and update automatical =?Utf-8?B?a2V2aW5t?= Microsoft Excel Worksheet Functions 21 19th May 2005 11:07 AM


Features
 

Advertising
 

Newsgroups
 


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