foxyginger
06-09-2017, 03:19 PM
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.
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.