ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with creating code?? (https://www.excelbanter.com/excel-programming/400684-help-creating-code.html)

Mekinnik

Help with creating code??
 
I am looking for some help on creating code to do the following.

1)create a new sheet from a formated(already created) sheet

2)name the new sheet what the combobox selection is, if it already exsists
have it alow the user to select another name

3)select the data(stored on two other sheets) for the new sheet based off of
a combobox selection

4)copy the data to the new sheet

And the kicker is I want all this to happen with the click of a button



meg99

Help with creating code??
 
On Nov 6, 11:43 am, Mekinnik
wrote:
I am looking for some help on creating code to do the following.
1)create a new sheet from a formated(already created) sheet
2)name the new sheet what the combobox selection is, if it already exsists
have it alow the user to select another name
3)select the data(stored on two other sheets) for the new sheet based off of
a combobox selection
4)copy the data to the new sheet
And the kicker is I want all this to happen with the click of a button

=========================
Create a menu button and attach this code:

Sub CopySheet()
NewName = InputBox("New Name")
If NewName = "" Then
Exit Sub
End If

ActiveSheet.Copy befo=Sheets(2)
NewSheet = ActiveSheet.Index
SheetCount = Sheets.Count
IsNewName = False
Do Until IsNewName = True
For s = 1 To SheetCount
If Sheets(s).Name = NewName Then
NewName = InputBox("New Name")
Exit For
End If
Next s
IsNewName = True
Loop
Sheets(NewSheet).Name = NewName
End Sub

Hope this helps

meg99



All times are GMT +1. The time now is 02:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com