ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Linking cells, with values and formats: VBA (https://www.excelbanter.com/excel-programming/445783-linking-cells-values-formats-vba.html)

Gonçalo Duarte

Linking cells, with values and formats: VBA
 
Hi!

I have various worksheets and I want to reference some cells and have the cell to have the original format (bold, color and pattern).

So for example A1=FEV12!A1, and A1 having the FEV12!A1's format, and updating everytime FEV12!A1's format changes.

I was reading a lot about it and came up with this sub, but it isn't working...

Sub FormatOfAssignment()
Dim rng As Range, cell As Range
Set rng = Selection
For Each cell In Intersect(rng, _
rng.SpecialCells(xlFormulas))
On Error GoTo passby
Range(Mid(cell.Formula, 2)).Copy
cell.PasteSpecial Paste:=xlFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
passby:
On Error GoTo 0
Next cell
End Sub

Can anyone help me out?

Thanks so much in advance!


All times are GMT +1. The time now is 06:08 PM.

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