您可以在不复制和粘贴的情况下做同样的事情。它需要更多代码,但不使用剪贴板,也不选择工作表上的任何内容。
它运行得更快。我很想知道这在您的工作计算机上是否比您已经尝试过的效果更好。
尝试这个:
Sub WriteInsteadOfCopyFormatting()
Dim wsJL As Worksheet 'Jobs List
Dim rng As Range ' Columns B through N
Dim dateRng As Range ' Column F
Dim numbersRng As Range ' Columns J through L
Dim NCMRRng As Range ' Column M
Dim lastRow As Long
Dim firstCopyRow As Long
Set wsJL = Sheets("Jobs List")
lastRow = wsJL.Range("B" & Rows.Count).End(xlUp).Row
firstCopyRow = 4
Set rng = wsJL.Range("B" & firstCopyRow & ":N" & lastRow)
Set dateRng = wsJL.Range("F" & firstCopyRow & ":F" & lastRow)
Set numbersRng = wsJL.Range("J" & firstCopyRow & ":J" & lastRow)
Set NCMRRng = wsJL.Range("M" & firstCopyRow & ":M" & lastRow)
With rng
.Interior.Color = 16777215
.Font.Name = "Calibri"
.Font.Size = 11
.Font.Color = vbBlack
.BorderAround Weight:=xlThin, Color:=vbBlack
End With
With rng.Borders(xlInsideVertical)
.Weight = xlThin
.Color = vbBlack
End With
With rng.Borders(xlInsideHorizontal)
.Weight = xlThin
.Color = vbBlack
End With
dateRng.NumberFormat = "d/mm/yyyy"
numbersRng.NumberFormat = "#,##0"
NCMRRng.NumberFormat = "0######"
End Sub