Linking cells, with values and formats: VBA

G

Gonçalo Duarte

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top