0

The Macro starts at cell F6.

I want to run the code, and then when it is finished, for the Macro to run the process again, this time from cell F7...... and then repeat the process from F8 and so on, until an empty cell.

I hope that makes sense.

The macro essentially opens a dataset from a pivot, adjusts the formatting and saves it down to a desktop as a name file.

I need to to this process x number of times, based on the number of files in the list that starts with F6.

    Range("F6").Select
    Selection.ShowDetail = True
    Columns("A:O").Select
    Columns("A:O").EntireColumn.AutoFit
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Selection.Copy
    Workbooks.Add
    ActiveSheet.Paste
    Range("A1").CurrentRegion.Select
    Sheets("Sheet1").Select
    Sheets("Sheet1").name = "MAP"

    Range("C2").Select
    Application.CutCopyMode = False
    ActiveCell.Copy

    Range("Q1").Select
    ActiveCell.PasteSpecial xlPasteValues


    Windows("Costs 2019.xlsm").Activate
    Sheets("Sheet1").Select
    ActiveWindow.SelectedSheets.Delete
    Range("H6").Select
    Application.CutCopyMode = False
    ActiveCell.Copy

    ActiveCell.FormulaR1C1 = " Electricity Invoicing August 2019"
    Windows("Book1").Activate

    Range("Q2").Select
    ActiveCell.PasteSpecial xlPasteValues

    Application.CutCopyMode = False
    Range("Q4").Select
    ActiveCell.FormulaR1C1 = "=CONCATENATE(R[-3]C,"""",R[-2]C)"

Dim FName           As String
Dim FPath           As String

    FPath = "C:\Users\" & Environ$("Username") & "\Desktop\"
    FName = Sheets("MAP").Range("Q4").Text
    Sheets("MAP").SaveAs Filename:=FPath & FName
    ActiveWindow.Close
    Range("A1").Select
End Sub
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

0 Answers0