Hi Guys,
I have reviewing many blogs and websites to see if there is a way to select the data inlcuding if users leave blank rows in the middle of them.
My code is not taking the rest of the rows with data since one row is empty.
Example:
From row 1 to row 3 have data, row 4 is empty and row 5 has data, so anyone can help me to change my code to include the row 5 in a dinamic way, that means the code can select the last row with data no matter if there are empty rows in the middle.
Appreciate your help
I have reviewing many blogs and websites to see if there is a way to select the data inlcuding if users leave blank rows in the middle of them.
My code is not taking the rest of the rows with data since one row is empty.
Example:
From row 1 to row 3 have data, row 4 is empty and row 5 has data, so anyone can help me to change my code to include the row 5 in a dinamic way, that means the code can select the last row with data no matter if there are empty rows in the middle.
VBA Code:
'Option Private Module
Sub Extraction()
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.AskToUpdateLinks = False
.EnableEvents = False
Dim MasterOne As Workbook
Set MasterOne = ThisWorkbook
'On Error Resume Next
' Andres template
Workbooks.Open Filename:="L:\2022 Hierarchy Changes\Consolidation\Hierarchy templates\Andres\Hierarchy_Template.xlsm"
Workbooks("Hierarchy_Template.xlsm").Activate
'CIM MApping Rule
Sheets("CIM Mapping Rule").Select
Range("A2:AV2", Range("A2:AV2").End(xlDown)).Select
Selection.Copy
MasterOne.Activate
Sheets("CIM Mapping Rule2").Select
Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAllUsingSourceTheme)
'GL Mapping Org Map
Workbooks("Hierarchy_Template.xlsm").Activate
Sheets("GL Mapping Org Map").Select
Range("A2:AV2", Range("A2:AV2").End(xlDown)).Select
Selection.Copy
MasterOne.Activate
Sheets("GL Mapping Org Map2").Select
Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAllUsingSourceTheme)
'GL Mapping Org Map
Workbooks("Hierarchy_Template.xlsm").Activate
Sheets("GL Mapping Org Map").Select
Range("A2:AV2", Range("A2:AV2").End(xlDown)).Select
Selection.Copy
MasterOne.Activate
Sheets("GL Mapping Org Map2").Select
Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAllUsingSourceTheme)
'GL Mapping Product Map
Workbooks("Hierarchy_Template.xlsm").Activate
Sheets("GL Mapping Product Map").Select
Range("A2:AV2", Range("A2:AV2").End(xlDown)).Select
Selection.Copy
MasterOne.Activate
Sheets("GL Mapping Product Map2").Select
Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAllUsingSourceTheme)
Workbooks("Hierarchy_Template.xlsm").Close savechanges:=False
.ScreenUpdating = True
.DisplayAlerts = True
.AskToUpdateLinks = True
End With
End Sub
Appreciate your help