Results 1 to 5 of 5

Thread: [RESOLVED] How to use a SpinButton to scroll through spreadsheets?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2011
    Posts
    110

    Resolved [RESOLVED] How to use a SpinButton to scroll through spreadsheets?

    Hi,

    I did a code to find sheets with some word in its name (word typed in a textbox; "InStr" to compare, etc). So, I saved numbers of these sheets in a vector (Dim sheets_with_my_word() as Integer).

    Now I need to export this vector to a new userform that contains a SpinButton (and labels) to alternate among worksheets with that word in the name.

    How could I do this?

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How to use a SpinButton to scroll through spreadsheets?

    try
    Code:
    set sht = sheets(sheets_with_my_word(spinbutton1.value))
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2011
    Posts
    110

    Re: How to use a SpinButton to scroll through spreadsheets?

    Thanks I tried and I agree that can be the solution, but


    "sheets_with_my_word()" received values in a userform and the spinbutton is in another, is it possible to "export" a variable from one userform to another?

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How to use a SpinButton to scroll through spreadsheets?

    declare a public variable at the top of a module, that way it will remain in scope even after the userform is unloaded
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2011
    Posts
    110

    Re: How to use a SpinButton to scroll through spreadsheets?

    Perfect. I declared in a module but I had forgotten to use "public".

    Thanks.

Tags for this Thread

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