Just trying to better understand this code you created (which is awsome BTW)
If I start my table on A4 Set rgD = Intersect(shD.Range("A4").CurrentRegion, shD.Range("A4").CurrentRegion.Offset(3, 1))
and all my RC references dont touch R1,2 or 3
sFile & "C5,""=""&R5C," & _
sFile & "C6,""=""&R6C," & _
sFile & "C8,""=""&RC1," & _
sFile & "C2,""=""&R4C," & _
is it safe to say anything I add to R1,2 or 3 will not effect the run?
Thank You
Code: Select all
Sub ImportActualsJBU()
Dim sPath As String
Dim sFile As String
Dim wbD As Workbook
Dim shD As Worksheet
Dim rgD As Range
Dim wbS As Workbook
Dim shS As Worksheet
Dim rgS As Range
Application.ScreenUpdating = False
sPath = "\\kewntfile01\sharedfile\Operations Planning\__Dashboards by RP\Airport Training_Class_Rosters\Airport_Class_Roster.xlsx"
If sPath = "False" Then Exit Sub
Set wbD = ThisWorkbook
Set shD = wbD.Sheets("Orientation")
Set rgD = Intersect(shD.Range("A4").CurrentRegion, shD.Range("A4").CurrentRegion.Offset(3, 1))
Workbooks.Open sPath, UpdateLinks:=False
Set wbS = ActiveWorkbook
Set shS = wbS.Sheets(1)
Set rgS = shS.Range("A1").CurrentRegion
sFile = "'[" & Split(sPath, "\")(UBound(Split(sPath, "\"))) & "]" & shS.Name & "'!"
rgD.FormulaR1C1 = _
"=SUMIFS(" & sFile & "C16," & _
sFile & "C5,""=""&R5C," & _
sFile & "C6,""=""&R6C," & _
sFile & "C8,""=""&RC1," & _
sFile & "C2,""=""&R4C," & _
sFile & "C1,""<>""&""""," & _
sFile & "C4,""<>""&""BP"")"
rgD.Value = rgD.Value
wbS.Close False
Application.ScreenUpdating = True
End Sub