ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How do I copy a cell (content AND format) from one worksheet to a. (https://www.excelbanter.com/excel-worksheet-functions/12398-how-do-i-copy-cell-content-format-one-worksheet.html)

Excel Format Copy

How do I copy a cell (content AND format) from one worksheet to a.
 
What worksheet function will copy both the content AND format of a cell in
one worksheet to a cell in another worksheet? I want to copy both text or
data and the format such as background color or border, under program
control. This would be a combination of both "=" function and "Format
Painter".

Jason Morin

You have to use VBA. What you could do is use a
worksheet change event so when you change the value in
for example, B3 on Sheet1, it copies the value and format
(change the formats first in B3 before the value), to
cell B10 on Sheet2. Something like:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim FromWS As Worksheet
Dim ToWS As Worksheet
Set FromWS = Sheets("Sheet1")
Set ToWS = Sheets("Sheet2")
Application.EnableEvents = False
Application.ScreenUpdating = False
With Target
If .Address = FromWS.[B3].Address Then
.Copy
With ToWS.[B10]
.PasteSpecial Paste:=xlPasteValues
.PasteSpecial Paste:=xlPasteFormats
End With
Application.CutCopyMode = False
End If
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

---
Click on the worksheet tab, select View Code, and paste
this into the window.

HTH
Jason
Atlanta, GA


-----Original Message-----
What worksheet function will copy both the content AND

format of a cell in
one worksheet to a cell in another worksheet? I want to

copy both text or
data and the format such as background color or border,

under program
control. This would be a combination of both "="

function and "Format
Painter".
.



All times are GMT +1. The time now is 07:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com