Results 1 to 13 of 13

Thread: show sheets into userform...

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,943

    show sheets into userform...

    Assuming i have many sheet into a wbook, named GENNAIO_2004, FEBBRAIO_2005, MARZO_2003 etcc....
    Is possible to show into a userform the list of all sheet and when i click on one of this, select and show the selected sheet?

    note:
    into wbook i have also a shett named "controllo" and "abicab" in effect for me is important only to show the sheets na,med with MONTH and YEAR.

  2. #2
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: show sheets into userform...

    How are you displaying these on the userform, in a listbox?
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,943

    Re: show sheets into userform...

    Quote Originally Posted by dannymking
    How are you displaying these on the userform, in a listbox?
    I am sorry into userform with the tipical drag bar with arrow up/down...

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: show sheets into userform...

    You can do something like this to generate a string listing of all sheets.
    VB Code:
    1. Public Function ListSheets() As String
    2.     Dim sSheets As String
    3.     Dim i As Integer
    4.     For i = 1 To ActiveWorkbook.Sheets.Count
    5.         sSheets = sSheets & ActiveWorkbook.Sheets(i).Name & ";"
    6.     Next
    7.     ListSheets = Left$(sSheets, Len(sSheets) - 1)
    8. End Function
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: show sheets into userform...

    I've just finished work so I'm not gonna have chance to explain..

    I'll leave it to the Guru robdog

    But you would be better of putting these into a listbox..
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: show sheets into userform...

    Then you can load your userform with this code behind it. The UF contains a combobox control which is probably best to use in this situation.
    VB Code:
    1. Private Sub UserForm_Initialize()
    2.     Dim ar() As String
    3.     Dim i As Integer
    4.    
    5.     ar = Split(ThisWorkbook.ListSheets, ";")
    6.     For i = 0 To UBound(ar)
    7.         ComboBox1.AddItem ar(i)
    8.     Next
    9.     Erase ar
    10. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: show sheets into userform...

    This would be the complete code behind the userform.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub ComboBox1_Click()
    4.     ActiveWorkbook.Sheets(ComboBox1.ListIndex + 1).Activate
    5. End Sub
    6.  
    7. Private Sub UserForm_Initialize()
    8.     Dim ar() As String
    9.     Dim i As Integer
    10.    
    11.     ar = Split(ThisWorkbook.ListSheets, ";")
    12.     For i = 0 To UBound(ar)
    13.         ComboBox1.AddItem ar(i)
    14.     Next
    15.     Erase ar
    16. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: show sheets into userform...

    Also add this code behind the userform for when the user types in the sheet name to switch to.
    VB Code:
    1. Private Sub ComboBox1_Change()
    2.     ActiveWorkbook.Sheets(ComboBox1.ListIndex + 1).Activate
    3. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,943

    Re: show sheets into userform...

    Quote Originally Posted by RobDog888
    This would be the complete code behind the userform.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub ComboBox1_Click()
    4.     ActiveWorkbook.Sheets(ComboBox1.ListIndex + 1).Activate
    5. End Sub
    6.  
    7. Private Sub UserForm_Initialize()
    8.     Dim ar() As String
    9.     Dim i As Integer
    10.    
    11.     ar = Split(ThisWorkbook.ListSheets, ";")
    12.     For i = 0 To UBound(ar)
    13.         ComboBox1.AddItem ar(i)
    14.     Next
    15.     Erase ar
    16. End Sub
    tks RobDog888 but i am a new bie not is possible to attach an example?
    Tks and pizza for you.
    Sal from Napoli.
    Last edited by luca90; Jul 27th, 2005 at 12:03 PM.

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: show sheets into userform...

    Ok, here is a complete working example.
    Attached Files Attached Files
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,943

    Re: show sheets into userform...

    Quote Originally Posted by RobDog888
    Ok, here is a complete working example.
    Hi Rob, tks for code... work fine.
    But have an idea for this:
    http://www.vbforums.com/showthread.php?t=351557
    Very important for me.
    Tks 2 pizza from Napoli.

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: show sheets into userform...

    Havent done much with automating IE but I will take a deeper look later. I need to take care of something.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,943

    Re: show sheets into userform...

    Quote Originally Posted by RobDog888
    Havent done much with automating IE but I will take a deeper look later. I need to take care of something.

    4 pizzas for you and 2 coffe from Napoli!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width