PC Review


Reply
Thread Tools Rate Thread

Copy the formatting of one cell to other cell

 
 
Subodh
Guest
Posts: n/a
 
      14th Oct 2009
I have a cell in sheet1.
I want to copy the cell formatting to other cell in other sheet
Sheet2.
=Sheet1!A1 won't work as it will just copy the cells value but not
formatting.
How can i copy the formatting using the VBA Code?
Thanks in advance.
 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      14th Oct 2009
Hi

Look at this:

Sheets("Sheet1").Range("A1").Copy
Sheets("Sheet2").Range("A2").PasteSpecial Paste:=xlFormats, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

Regards,
Per

"Subodh" <(E-Mail Removed)> skrev i meddelelsen
news:0f6b039c-db2b-4374-90e4-(E-Mail Removed)...
>I have a cell in sheet1.
> I want to copy the cell formatting to other cell in other sheet
> Sheet2.
> =Sheet1!A1 won't work as it will just copy the cells value but not
> formatting.
> How can i copy the formatting using the VBA Code?
> Thanks in advance.


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      14th Oct 2009
Record a macro when you do a copy|paste special|formats and you'll have the
syntax.

Subodh wrote:
>
> I have a cell in sheet1.
> I want to copy the cell formatting to other cell in other sheet
> Sheet2.
> =Sheet1!A1 won't work as it will just copy the cells value but not
> formatting.
> How can i copy the formatting using the VBA Code?
> Thanks in advance.


--

Dave Peterson
 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      14th Oct 2009
Did you want to copy the values also? If not, will there be other values in
the destination cells?

--
Rick (MVP - Excel)


"Subodh" <(E-Mail Removed)> wrote in message
news:0f6b039c-db2b-4374-90e4-(E-Mail Removed)...
>I have a cell in sheet1.
> I want to copy the cell formatting to other cell in other sheet
> Sheet2.
> =Sheet1!A1 won't work as it will just copy the cells value but not
> formatting.
> How can i copy the formatting using the VBA Code?
> Thanks in advance.


 
Reply With Quote
 
Subodh
Guest
Posts: n/a
 
      21st Oct 2009
On Oct 14, 7:36*am, "Rick Rothstein"
<rick.newsNO.S...@NO.SPAMverizon.net> wrote:
> Did you want to copy the values also? If not, will there be other values in
> the destination cells?
>
> --
> Rick (MVP - Excel)
>
> "Subodh" <getsub...@gmail.com> wrote in message
>
> news:0f6b039c-db2b-4374-90e4-(E-Mail Removed)...
>
>
>
> >I have acellin sheet1.
> > I want to copy thecellformattingto othercellin other sheet
> > Sheet2.
> > =Sheet1!A1 won't work as it will just copy the cells value but not
> >formatting.
> > How can i copy theformattingusing the VBA Code?
> > Thanks in advance.- Hide quoted text -

>
> - Show quoted text -

The above code works to copy the formatting but not the values.
I want to copy the values also to the destination cell.
Also, I want the code to run whenever the change is made in the cell
A1 of Sheet1.
 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      21st Oct 2009
You didn't say which "other cell" on Sheet2 you wanted to copy A1 from
Sheet1 to, so I guessed at C3 (change that as desired)...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) = "A1" Then
Target.Copy Worksheets("Sheet2").Range("C3")
End If
End Sub

This is event code and must go in Sheet1's code window. To do that,
right-click the tab at the bottom of Sheet1, select View Code from the popup
menu that appears and then copy/paste the above code into the code window
that appeared. Now, whenever you go back to Sheet1 and (manually, not
through a formula) change the value in A1, C3 on Sheet2 will have the same
value in it with the same formatting.

--
Rick (MVP - Excel)


"Subodh" <(E-Mail Removed)> wrote in message
news:5a38eaa0-e49f-40f5-8ddf-(E-Mail Removed)...
On Oct 14, 7:36 am, "Rick Rothstein"
<rick.newsNO.S...@NO.SPAMverizon.net> wrote:
> Did you want to copy the values also? If not, will there be other values
> in
> the destination cells?
>
> --
> Rick (MVP - Excel)
>
> "Subodh" <getsub...@gmail.com> wrote in message
>
> news:0f6b039c-db2b-4374-90e4-(E-Mail Removed)...
>
>
>
> >I have acellin sheet1.
> > I want to copy thecellformattingto othercellin other sheet
> > Sheet2.
> > =Sheet1!A1 won't work as it will just copy the cells value but not
> >formatting.
> > How can i copy theformattingusing the VBA Code?
> > Thanks in advance.- Hide quoted text -

>
> - Show quoted text -

The above code works to copy the formatting but not the values.
I want to copy the values also to the destination cell.
Also, I want the code to run whenever the change is made in the cell
A1 of Sheet1.

 
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
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Options Yuvraj Microsoft Excel Misc 0 29th Jun 2009 11:20 AM
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Yuvraj Microsoft Excel Misc 0 26th Jun 2009 06:01 PM
Copy Cell Formatting =?Utf-8?B?Q2hyaXN0bWFzIE1heQ==?= Microsoft Excel Programming 2 20th Oct 2006 07:04 PM
How to copy formatting when moving from cell to variable to another cell on another worksheet kls Microsoft Excel Programming 1 11th Sep 2004 10:42 PM
Re: Copy Formatting of Cell Frank Kabel Microsoft Excel Programming 3 14th May 2004 10:35 PM


Features
 

Advertising
 

Newsgroups
 


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