Yellow Snow
New Member
- Joined
- Jul 16, 2021
- Messages
- 5
- Office Version
- 365
- Platform
- Windows
Hello Everyone,
Just wondering how I could:
1. Specify a file path location in the below code from a specific cell from a "master sheet" tab.
2. Copy data formats from the source and retain the format in the destination paste location.
Sub Another_Possibility()
Dim wb1 As Workbook, wb2 As Workbook, i As Long
Dim frFile, rngArray
Application.ScreenUpdating = False
Set wb1 = ActiveWorkbook
rngArray = Array("D10", "D16:D26", "D31:D41", "J10", "J16:J26", "J31:J41", "P10", "P16:P26", "P31:P41", "V10", "V16:V26", "V31:V41")
frFile = Application.GetOpenFilename("Excel Files (*.xls*), *.xls*", _
, "Please select file to copy from")
If frFile = False Then Exit Sub
Set wb2 = Workbooks.Open(frFile)
For i = LBound(rngArray) To UBound(rngArray)
wb1.Sheets("Sheet3").Range(rngArray(i)).Value = wb2.Sheets("Sheet1").Range(rngArray(i)).Value
Next i
wb2.Close SaveChanges:=False
Set wb2 = Nothing
Set wb1 = Nothing
Application.ScreenUpdating = True
End Sub
Just wondering how I could:
1. Specify a file path location in the below code from a specific cell from a "master sheet" tab.
2. Copy data formats from the source and retain the format in the destination paste location.
Sub Another_Possibility()
Dim wb1 As Workbook, wb2 As Workbook, i As Long
Dim frFile, rngArray
Application.ScreenUpdating = False
Set wb1 = ActiveWorkbook
rngArray = Array("D10", "D16:D26", "D31:D41", "J10", "J16:J26", "J31:J41", "P10", "P16:P26", "P31:P41", "V10", "V16:V26", "V31:V41")
frFile = Application.GetOpenFilename("Excel Files (*.xls*), *.xls*", _
, "Please select file to copy from")
If frFile = False Then Exit Sub
Set wb2 = Workbooks.Open(frFile)
For i = LBound(rngArray) To UBound(rngArray)
wb1.Sheets("Sheet3").Range(rngArray(i)).Value = wb2.Sheets("Sheet1").Range(rngArray(i)).Value
Next i
wb2.Close SaveChanges:=False
Set wb2 = Nothing
Set wb1 = Nothing
Application.ScreenUpdating = True
End Sub