I am looking to write a macro to copy the format of only the visible (i.e. non-hidden, non-filtered out) cells of a selection in one sheet into only the visible cells in a selection in another sheet.
My VBA is a bit rusty, so if anyone can either help me with the code I wrote myself, or provide an alternative bit of code, I would be very thankful.
Here is my current code (with commented-out code incase someone suggests i uncomment that code):
Sub Copy_Paste_Visible()
Set CopyRng = Application.Selection
CopyRng = CopyRng.SpecialCells(xlCellTypeVisible).Copy' _
'Destination:=Range("A1").Offset(ColumnOffset:=1)
Set PasteRng = Application.InputBox("Paste to :", xTitleId, Type:=8)
PasteRng = PasteRng.SpecialCells(xlCellTypeVisible) '.Copy _
'Destination:=Range("A11").Offset(ColumnOffset:=1)
'CopyRng.Copy
PasteRng.Parent.Activate
'PasteRng.Activate
PasteRng.PasteSpecial xlPasteFormats
Application.CutCopyMode = False
End Sub
With this code, on line
PasteRng.Parent.Activate
I get the following error message:
If anyone is able to provide any input, that would be great.