dpaton05
Well-known Member
- Joined
- Aug 14, 2018
- Messages
- 2,392
- Office Version
- 365
- 2016
- Platform
- Windows
What does this line of code do in the following procedure?
Code:
With srcWS.Range("A:A,B:B,H:H")
Code:
Private Sub CmdSend_Click()
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim desWS As Worksheet
Dim srcWS As Worksheet
Set srcWS = ThisWorkbook.Sheets("NPSS_quote_sheet")
Set desWS = Workbooks("Costing tool.xlsm").Sheets("Home")
Dim lastRow1 As Long
Dim lastRow2 As Long
lastRow1 = srcWS.Range("B" & srcWS.Rows.Count).End(xlUp).Row
lastRow2 = desWS.Range("A" & srcWS.Rows.Count).End(xlUp).Row
Dim i As Long
Dim header As Range
Dim x As Long
With srcWS.Range("A:A,B:B,H:H")
For i = 1 To .Areas.Count
x = .Areas(i).Column
Set header = desWS.Rows(4).Find(.Areas(i).Cells(10), LookIn:=xlValues, lookat:=xlWhole)
If Not header Is Nothing Then
srcWS.Range(srcWS.Cells(11, x), srcWS.Cells(lastRow1, x)).Copy
desWS.Cells(lastRow2 + 1, header.Column).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
End If
Next i
End With
With desWS
.Range("D" & lastRow2 + 1 & ":D" & .Range("A" & .Rows.Count).End(xlUp).Row) = srcWS.Range("G7")
.Range("F" & lastRow2 + 1 & ":F" & .Range("A" & .Rows.Count).End(xlUp).Row) = srcWS.Range("B7")
.Range("G" & lastRow2 + 1 & ":G" & .Range("A" & .Rows.Count).End(xlUp).Row) = srcWS.Range("B6")
End With
With Application
.CutCopyMode = False
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub