Copying Formatting For Existing VBA code

Tmini

New Member
Joined
Mar 22, 2014
Messages
44
Office Version
  1. 365
Platform
  1. Windows
Hi
I would like to copy the format of the cells. It relates to just one particular line in my VBA code but I'm unsure how to add in the code to do this. I only want the formats copied for the final line of my code,
VBA Code:
        Ws4.Range("A2:C22").Offset(lngrow2, 0).Value = ws.Range("I63:K83").Value
,
the main code is below, Is anyone able to help me with this?

VBA Code:
  Set ws = Wb.Sheets("Total Quantities")
        On Error GoTo 0
        If Not ws Is Nothing Then
        If lngrow1 = 0 Then
        lngrow1 = 5
    Else
        lngrow2 = lngrow2 + 22
        lngrow1 = lngrow1 + 1
        lngrow = lngrow + 284
    End If
        ws1.Cells(lngrow1, "A").Value = ws.Range("A1").Value
        ws1.Cells(lngrow1, "B").Value = ws.Range("I2").Value
        ws1.Cells(lngrow1, "C").Value = ws.Range("C2").Value
        ws1.Cells(lngrow1, "E").Value = ws.Range("C3").Value
        ws1.Cells(lngrow1, "G").Value = ws.Range("C4").Value
        ws2.Cells(lngrow1, "B").Value = ws.Range("B8").Value
        ws2.Cells(lngrow1, "C").Value = ws.Range("B9").Value
        ws2.Cells(lngrow1, "D").Value = ws.Range("B10").Value
        ws2.Cells(lngrow1, "E").Value = ws.Range("B11").Value
        ws2.Cells(lngrow1, "F").Value = ws.Range("B12").Value
        ws2.Cells(lngrow1, "G").Value = ws.Range("B13").Value
        ws2.Cells(lngrow1, "H").Value = ws.Range("B14").Value
        ws3.Range("A2:A228").Offset(lngrow, 0).Value = ws.Range("A16:A242").Value
        ws3.Range("B2:B228").Offset(lngrow, 0).Value = ws.Range("C16:C242").Value
        ws3.Range("E2:E228").Offset(lngrow, 0).Value = ws.Range("H16:H242").Value
        ws3.Range("D2:D228").Offset(lngrow, 0).Value = ws.Range("E16:E242").Value
        ws3.Range("F2:F228").Offset(lngrow, 0).Value = ws.Range("F16:F242").Value
        ws3.Range("A229:A275").Offset(lngrow, 0).Value = ws.Range("I16:I62").Value
        ws3.Range("b229:b275").Offset(lngrow, 0).Value = ws.Range("J16:J62").Value
        ws3.Range("d229:d275").Offset(lngrow, 0).Value = ws.Range("K16:K62").Value
        ws3.Range("e229:e275").Offset(lngrow, 0).Value = ws.Range("l16:l62").Value
        ws3.Range("A276:A284").Offset(lngrow, 0).Value = ws.Range("I64:I72").Value
        ws3.Range("b276:b284").Offset(lngrow, 0).Value = ws.Range("J64:J72").Value
        ws3.Range("d276:d284").Offset(lngrow, 0).Value = ws.Range("K64:K72").Value
        Ws4.Range("A2:C22").Offset(lngrow2, 0).Value = ws.Range("I63:K83").Value
        
        End If
            .Close
        End With
    Next i

Cleanup:
    Set fldr = Nothing
End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,223,275
Messages
6,171,123
Members
452,381
Latest member
Nova88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top