ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Using Combo Boxes as a function (https://www.excelbanter.com/excel-worksheet-functions/26218-using-combo-boxes-function.html)

Jez

Using Combo Boxes as a function
 
Hi,

I want to have a list in my combo box that once selected it will then on a
new sheet name the sheet tab as selected from my combo box.

so if in my combo box i had:
monday
tuesday
Wednesday

I want to select tuesday and on another sheet it renames the sheet tab with
tuesday.

Thanks,
Jez.

Jason Morin

Try something like:

Private Sub ComboBox1_Change()

Dim NewSh As Worksheet
Dim ComboBoxVal As String

ComboBoxVal = ComboBox1.Value
Set NewSh = Sheets.Add

On Error GoTo InvalidName
NewSh.Name = ComboBoxVal
Exit Sub

InvalidName:
MsgBox "Invalid name or workhseet with " & _
"the same name already exists."
Application.DisplayAlerts = False
NewSh.Delete
Application.DisplayAlerts = True

End Sub

---
HTH
Jason
Atlanta, GA


"Jez" wrote:

Hi,

I want to have a list in my combo box that once selected it will then on a
new sheet name the sheet tab as selected from my combo box.

so if in my combo box i had:
monday
tuesday
Wednesday

I want to select tuesday and on another sheet it renames the sheet tab with
tuesday.

Thanks,
Jez.



All times are GMT +1. The time now is 08:20 AM.

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