Hello,
Can someone look at the below code and tell me where I am making mistake. I have written this code to match a column between two tabs "Main" and "Backup". If the column number matches, the code should copy the row formatting of that column number from "Backup" sheet to "Main" sheet.
Currently, it is copying the formatting from "Main" sheet to "Main" sheet itself. Dont know where I am making mistake. Thanks.
Sub Rowformat()
Dim Sht1Rng As Range
Dim Sht2Rng As Range
Dim D As Range
'Compares the ID cell in both worksheets to each other
Set Sht1Rng = Worksheets("Main").Range("B6", Worksheets("Main").Range("B65536").End(xlUp))
Set Sht2Rng = Worksheets("Backup").Range("B6", Worksheets("Backup").Range("B65536").End(xlUp))
For Each B In Sht1Rng
Set D = Sht2Rng.Find(B.Value, LookIn:=xlValues)
'If same value found in col B of "Backup" sheet then copy
If Not D Is Nothing Then
Sheets("Backup").Select
Range(Cells(D.Row, 1), Cells(D.Row, 58)).Copy
Sheets("Main").Select
Range(Cells(D.Row, 1), Cells(D.Row, 58)).PasteSpecial xlPasteFormats
End If
Set D = Nothing
Next B
End Sub
Bookmarks