Good morning,
I was wondering if someone could help me with a macro that automatically selects the following ranges for each "block" of data delimited by cells in column A. I have my own macro that will copy each "block" to a new workbook and save it as its own file (once the range is selected; see below), but I want to automate the process of selecting each data "block" down column A.
Ideally, the "Automatic Range Selection Macro" will:
1. Select block 1,
Block 1
Range selection 1.PNG
2. Run my "Move selected range to new workbook & save" macro (see code below).
3. And then continue automatically to block 2 etc...until the last block is selected, copied and saved.
Range Selection 2.PNG
"Move selected range to new workbook & save" macro
Sub CopyandSave()
Dim Path As String
Dim filename As String
Dim xWs As Worksheet
Dim rng As Range
Set rng = Application.Selection
Application.Workbooks.Add
Set xWs = Application.ActiveSheet
rng.Copy Destination:=xWs.Range("A1")
Path = "DESTINATION FOLDER\"
filename = Range("C2")
ActiveWorkbook.SaveAs filename:=Path & filename & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
ActiveWorkbook.Close
End Sub
M
Bookmarks