Results 1 to 3 of 3

Thread: VBA Code to replace action if MACRO is run again

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    VBA Code to replace action if MACRO is run again

    Background: I created a MACRO to create a new spreadsheet named "DATA" which copies the information on another spreadsheet to the newly created "DATA" spreadsheet with the paste special feature of "values and number formats" (no formulas included) so that the new spreadsheet would link to a database I use.

    Here is the MACRO I wrote:

    Sub CreateDataForm()
     
    Sheets.Add.Name = "DATA"
    Sheets("DATA").Move Before:=Sheets(1)
    Sheets("ETL").Select
    Cells.Select
    Selection.Copy
    Sheets("DATA").Select
    Cells.Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
    xlNone, SkipBlanks:=False, Transpose:=False
    Cells.EntireColumn.AutoFit
    Application.CutCopyMode = False
     
    End Sub
    Issue: I now would like to know how to edit my MACRO so that when I rerun the button after changes are made it will delete the newly made "DATA" tab and create a new one with the new information, also named "DATA".

    I've researched looping, but I only need it to complete this action if the MACRO button is pushed again. I am new to VBA and MACROS so stating answers as simply as possible and including actual code would be very helpful.
    Last edited by SamT; 06-09-2017 at 05:15 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •