Hi, the below code opens workbook based on the rngImportPath, how can the code be amended so that copy to shtDst be tailored. So I would like to to copy 3 times
So B2:B copy ShtDst.Range("A6"
D2:D copy......................("B6")
A2:D copy.......................("C6")
With .Range("A2:R" & lstSrcCellRwNum)
.Copy
shtDst.Range("A5").PasteSpecial xlPasteValues
End With
So B2:B copy ShtDst.Range("A6"
D2:D copy......................("B6")
A2:D copy.......................("C6")
With .Range("A2:R" & lstSrcCellRwNum)
.Copy
shtDst.Range("A5").PasteSpecial xlPasteValues
End With
Code:
strFileName = Range("rngImportPath") & ".xls"
If Dir(strFileName) = "" Then
MsgBox prompt:="The File does not exist", _
Buttons:=vbOKOnly + vbInformation
Exit Function
Else
Set wkbSrc = Workbooks.Open(strFileName)
Set shtSrc = wkbSrc.Worksheets(1)
Set wkbThis = ThisWorkbook
Set shtDst = wkbThis.Sheets(gstrRawHoldings)
End If
With shtSrc
Set lstRowSrc = .Cells(.Rows.Count, "A").End(xlUp)
lstSrcCellRwNum = lstRowSrc.Row
With shtDst
On Error Resume Next
Intersect(.UsedRange, .Range("A5:R" & Rows.Count)).ClearContents
On Error GoTo 0
End With
With .Range("A2:R" & lstSrcCellRwNum)
.Copy
shtDst.Range("A5").PasteSpecial xlPasteValues
End With
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
End With