How to copy and paste a sheet by pressing a button to another work

T

TG

Good morning,

I have a sheet called "main", in this sheet there are 8 drop down menues.
Once all of the selections have been made a sheet called "BOM" has all of the
materials needed for the desired selection ( lets say we are building a
computer, the "BOM" sheet automatically generates what you need for that
computer depending on the configurations you have chosen in the "main"
sheet), now once the person makes their selection a nomenclature appears (i.e
pc_xp_sp2) in the "main" sheet. I would like to have a button so when the
person presses it creates a new workbook (being able to choose the name for
the new workbook would be great but not necessary), once this button is
pressed it creates a new workbook but also takes the nomenclature and puts it
as the name for the new tab in the newly created workbook, this new tab would
have what was in the "BOM" in the original workbook. Once the button is
pressed and has created the new work book with the new tab, I would like the
user to have the option to make a new selection with the drop down menues,
and have a second button so this button will copy and paste the new "BOM"
(everytime new selections are made the "BOM" is updated) sheet to a new tab
in the newly created workbook (with the new nomenclature name). I would like
the user to have the abililty to do this as many times as possible, each time
creating a new tab with the nomenclature in the same newly created workbook,
unless he/she wants a new workbook and presses button 1.

I hope this makes sense, and would highly appreciate your help.

Thank you in advance,

TG
 
P

Patrick Molloy

Option Explicit
Dim wb As Workbook

Sub AddToBook()
Dim ws As Worksheet
If wb Is Nothing Then
Set wb = Workbooks.Add(xlWBATWorksheet)
Set ws = wb.ActiveSheet
Else
Set ws = wb.Worksheets.Add
End If


ws.Name = ThisWorkbook.Worksheets("Main").Range("B8").Value

ThisWorkbook.Activate

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top