Hi
I have the below code which copies a range data from a workbook and it works well. I just want to copy formatting such as borders and font colour etc. I have tried using .PasteSpecial xlPasteValuesAndNumberFormats as per below but it doesn't seem to work.
Clearly I am doing something wrong and I am unsure where I am going wrong. Is someone able to help me out
I have the below code which copies a range data from a workbook and it works well. I just want to copy formatting such as borders and font colour etc. I have tried using .PasteSpecial xlPasteValuesAndNumberFormats as per below but it doesn't seem to work.
Code:
= ws.Range("A1:A13").[COLOR=#333333]PasteSpecial xlPasteValuesAndNumberFormats[/COLOR]
Clearly I am doing something wrong and I am unsure where I am going wrong. Is someone able to help me out
Code:
Filename = Split(x(i), "\")(UBound(Split(x(i), "\"))) Set Wb = Workbooks(Filename)
Set ws = Nothing
On Error Resume Next
Set ws = Wb.Sheets("Sheet5")
On Error GoTo 0
If Not ws Is Nothing Then
ws1.Range("A1:A13").Offset(lngrow, 0).Value = ws.Range("A1:A13").Value
ws1.Range("b1:b13").Offset(lngrow, 0).Value = ws.Range("b1:b13").Value
ws1.Range("c1:c13").Offset(lngrow, 0).Value = ws.Range("c1:c13").Value
ws1.Range("A14:A231").Offset(lngrow, 0).Value = ws.Range("A16:A233").Value
ws1.Range("B14:B231").Offset(lngrow, 0).Value = ws.Range("C16:C233").Value
ws1.Range("E14:E231").Offset(lngrow, 0).Value = ws.Range("H16:H233").Value
ws1.Range("D14:D231").Offset(lngrow, 0).Value = ws.Range("d16:d233").Value
ws1.Range("F14:F231").Offset(lngrow, 0).Value = ws.Range("F16:F233").Value
ws1.Range("A232:A277").Offset(lngrow, 0).Value = ws.Range("I16:I61").Value
ws1.Range("b232:b277").Offset(lngrow, 0).Value = ws.Range("J16:J61").Value
ws1.Range("d232:d277").Offset(lngrow, 0).Value = ws.Range("K16:K61").Value
ws1.Range("e232:e277").Offset(lngrow, 0).Value = ws.Range("l16:l61").Value
lngrow = lngrow + 278
End If
Wb.Close False
End With
Next i