ryanexcelent
New Member
- Joined
- Nov 2, 2018
- Messages
- 1
I have declared my variable to make sense of the below at the top. However, once the TemplateFile section has run, I cannot get VBA to get back to Account workbook, navigate to the Records spreadsheet and then select the used range to sort them using the control + shift + down method and control + shift + right.
TemplateFile = Application.GetOpenFilename(, , "Please open the workbook that serves as a blank template for missing data files.")
' Open the file dialog
Set diaFolder = Application.FileDialog(msoFileDialogFolderPicker)
diaFolder.Title = "Please select a folder to output the results."
diaFolder.AllowMultiSelect = False
diaFolder.Show
output = diaFolder.SelectedItems(1)
Set diaFolder = Nothing
'this section is to sort the data to ensure the loop as accurate data to loop through
Workbooks("Account").Worksheets("Records").Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveWorkbook.Worksheets("Records").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Records").AutoFilter.Sort.SortFields.Add Key:=Range _
("A2:A407"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Records").AutoFilter.Sort.SortFields.Add Key:=Range _
("E2:E407"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Records").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
TemplateFile = Application.GetOpenFilename(, , "Please open the workbook that serves as a blank template for missing data files.")
' Open the file dialog
Set diaFolder = Application.FileDialog(msoFileDialogFolderPicker)
diaFolder.Title = "Please select a folder to output the results."
diaFolder.AllowMultiSelect = False
diaFolder.Show
output = diaFolder.SelectedItems(1)
Set diaFolder = Nothing
'this section is to sort the data to ensure the loop as accurate data to loop through
Workbooks("Account").Worksheets("Records").Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveWorkbook.Worksheets("Records").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Records").AutoFilter.Sort.SortFields.Add Key:=Range _
("A2:A407"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Records").AutoFilter.Sort.SortFields.Add Key:=Range _
("E2:E407"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Records").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With