Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default combo box nightmare

Hi de hi

I am using a combo box (cmbindivlist) on a form (frmindiv) which is
populated from a column on form (d1) to view existing worksheets or create a
new one if it doesn't exist!

I am using:


Private Sub cmdviewi_Click()

If Cmbindivlist.ListIndex -1 Then
indivsh = Cmbindivlist.Name
If sheetexists(indivsh) Then

Sheets(Cmbindivlist.Name).Select

Else: Call makesheeti

End If
Sheets(indivsh).Visible = True
Range("a1:a1").Select
End If

End Sub

the sheetexsts function is in a separate module:

Public Function sheetexists(ByVal indivsh) As Boolean
' Returns TRUE if sheet exists in the active workbook
Dim x As Object
On Error Resume Next
Set x = ActiveWorkbook.Sheets(indivsh)
If Err = 0 Then sheetexists = True Else: sheetexists = False

End Function
(obtained and tweaked from this site)


but when I break on the cmdviewi sub I notice that indivsh is "" result....
a new sheet created called cmbindivlist.

I know I'm probably missing something really simple but hey...that's me.

I would really appreciate any help

And worry...I have more.

Thanks in advance.
--
Jabba
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default combo box nightmare

Replace

indivsh = Cmbindivlist.Name

with

indivsh = Cmbindivlist.Value

--
Regards

Juan Pablo González

"Jabba" wrote in message
...
Hi de hi

I am using a combo box (cmbindivlist) on a form (frmindiv) which is
populated from a column on form (d1) to view existing worksheets or create

a
new one if it doesn't exist!

I am using:


Private Sub cmdviewi_Click()

If Cmbindivlist.ListIndex -1 Then
indivsh = Cmbindivlist.Name
If sheetexists(indivsh) Then

Sheets(Cmbindivlist.Name).Select

Else: Call makesheeti

End If
Sheets(indivsh).Visible = True
Range("a1:a1").Select
End If

End Sub

the sheetexsts function is in a separate module:

Public Function sheetexists(ByVal indivsh) As Boolean
' Returns TRUE if sheet exists in the active workbook
Dim x As Object
On Error Resume Next
Set x = ActiveWorkbook.Sheets(indivsh)
If Err = 0 Then sheetexists = True Else: sheetexists = False

End Function
(obtained and tweaked from this site)


but when I break on the cmdviewi sub I notice that indivsh is ""

result....
a new sheet created called cmbindivlist.

I know I'm probably missing something really simple but hey...that's me.

I would really appreciate any help

And worry...I have more.

Thanks in advance.
--
Jabba



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default combo box nightmare

Thanks for the suggestion Juan Pablo but it didn't work.

Using 'value' instead of 'name' returns the index of the selection.

I did, however , use a different method....

-----------------------------------------------

Private Sub cmdviewi_Click()

If Cmbindivlist.ListIndex -1 Then
indivsh = Cmbindivlist.Text

For Each wks In Worksheets
If wks.Name = indivsh Then
Sheets(Cmbindivlist.Text).Select

On Error GoTo makesheeta
Exit Sub
End If

Next wks

makesheeta:


Sheets("template").Copy befo=Sheets("template")
ActiveSheet.Name = indivsh



End If
End Sub

-------------------------------------------------

which seems to work. Not very good code but hell let's not worry about that
huh!

Thanks again

"Juan Pablo González" wrote:

Replace

indivsh = Cmbindivlist.Name

with

indivsh = Cmbindivlist.Value

--
Regards

Juan Pablo González

"Jabba" wrote in message
...
Hi de hi

I am using a combo box (cmbindivlist) on a form (frmindiv) which is
populated from a column on form (d1) to view existing worksheets or create

a
new one if it doesn't exist!

I am using:


Private Sub cmdviewi_Click()

If Cmbindivlist.ListIndex -1 Then
indivsh = Cmbindivlist.Name
If sheetexists(indivsh) Then

Sheets(Cmbindivlist.Name).Select

Else: Call makesheeti

End If
Sheets(indivsh).Visible = True
Range("a1:a1").Select
End If

End Sub

the sheetexsts function is in a separate module:

Public Function sheetexists(ByVal indivsh) As Boolean
' Returns TRUE if sheet exists in the active workbook
Dim x As Object
On Error Resume Next
Set x = ActiveWorkbook.Sheets(indivsh)
If Err = 0 Then sheetexists = True Else: sheetexists = False

End Function
(obtained and tweaked from this site)


but when I break on the cmdviewi sub I notice that indivsh is ""

result....
a new sheet created called cmbindivlist.

I know I'm probably missing something really simple but hey...that's me.

I would really appreciate any help

And worry...I have more.

Thanks in advance.
--
Jabba




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
nightmare formula [email protected] Excel Worksheet Functions 4 March 15th 09 10:36 AM
PivotTable Nightmare Sandi Excel Discussion (Misc queries) 3 March 3rd 07 04:34 PM
PivotTable Nightmare MarkM Excel Discussion (Misc queries) 1 August 14th 06 07:41 PM
VBA Autofilter nightmare Jmbostock[_9_] Excel Programming 11 January 29th 04 12:24 AM
Protection nightmare Joe Bannister Excel Programming 1 January 27th 04 05:15 PM


All times are GMT +1. The time now is 12:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"