+ Reply to Thread
Results 1 to 14 of 14

Spinbutton to cycle through named ranges

  1. #1
    Registered User
    Join Date
    05-11-2017
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    22

    Question Spinbutton to cycle through named ranges

    Hi,

    I will try to explain my problem.

    I have a bunch of named ranges

    Range1, Range2, Range3, Range 4, ...


    I can sort the named ranges. So depending on how they are sorted, they are in a different order.

    Now I want to create a form to display the information in the ranges. And I want to use a spinbutton to move forward or backwards through the ranges.


    Can anybody help me with the code I have to use for the spinbutton?

    Thanks!

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Spinbutton to cycle through named ranges

    How do you want to display the information in the ranges?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Spinbutton to cycle through named ranges

    Here is the general idea. Where I have put code to display the name and range address, you will need to replace it with code to "display the information in the ranges".

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-11-2017
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    22

    Re: Spinbutton to cycle through named ranges

    I see. But you use labels? I have no labels. I will explain how I tried to make this work.

    I have about 100 ranges. Rng1, Rng2, Rng3, Rng4,...

    And I want a spinbutton to cycle through and display the information of these ranges in another range, called printrng for example.
    Which is linked to another sheet for printing.

    Does this clarify it a little bit?

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Spinbutton to cycle through named ranges

    No, I'm sorry, it doesn't. Because I still don't know what "display the information of these ranges in another range" means.

    You started out by saying you wanted "a form to display the information". Do you now mean that you want to copy the range selected by the spin button and then paste it somewhere else on a worksheet, rather than display on the form?

    My labels are just placeholders to show that something happens when you click the spin button. You need to replace the code in SpinButton1_Change to copy from Application.Names(Me.SpinButton1).RefersToRange and paste it wherever you want it.

  6. #6
    Registered User
    Join Date
    05-11-2017
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    22

    Re: Spinbutton to cycle through named ranges

    I'm not doing a good job explaining this...

    Now I'm trying it without a form. Just a spin button on the sheet and copy the selected range and paste it to somewhere else as you mentioned above.

    I thought this would be an easier way. But I still havent figured it out.

  7. #7
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Spinbutton to cycle through named ranges

    Maybe, for a start:
    5 Named ranges from sheet1 are pasted into sheet2
    The spinbutton is used to select 1 - 5, via G1
    formulas in column I select the named range and values from it:

    =INDEX(INDIRECT(INDEX(The_List,G1,1)),1,1)
    =ROWS(INDIRECT(INDEX(The_List,G1,1)))
    =RANDBETWEEN(2,$I$2)
    =INDEX(INDIRECT(INDEX(The_List,G1,1)),I3)
    Attached Files Attached Files
    Last edited by protonLeah; 11-28-2018 at 10:55 PM. Reason: delete spinbutton macro
    Ben Van Johnson

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Spinbutton to cycle through named ranges

    Quote Originally Posted by ymmotteov View Post
    I'm not doing a good job explaining this...

    Now I'm trying it without a form. Just a spin button on the sheet and copy the selected range and paste it to somewhere else as you mentioned above.

    I thought this would be an easier way. But I still havent figured it out.
    If protonLeah's solution still does not answer your question then please attach your file. The paper clip icon does not work for attachments. To attach a file, under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.

  9. #9
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: Spinbutton to cycle through named ranges

    Without sample sheets we are all guessing what you are trying to achieve.
    Two sample sheets, are all that is required, what your source data looks like and what end product do you want.
    I have attached a couple of examples of what I envisage you are trying to do.
    Both are elements from far more complex application I have used in the past and I have just extracted the bare bones.
    The KPI file is used to extract data for interactive charts in PowerPoint utalising data import from Sage accounts.
    The MEMBER file is adapted from one I used in a club admin app, in both cases the source data has been desensitised for data protection.
    The KPI file is entirely formula driven, the MEMBER file has a FORM and VBA backed, to enter new data press CLEAR first, to edit existing select from listbox.
    Hopefully you can then develop a clearer picture as to which direction you wish to take.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    05-11-2017
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    22

    Re: Spinbutton to cycle through named ranges

    I understand. I've made an example.

    In the detail page there are ranges (missions for transport). They can be sorted (on time) by using a Macro (CTRL-X).

    In the other page I would like to have a scroll button of some kind to cycle through the ranges and display that range.

    Hope this makes it a little bit more understandable.

    Thank you guys for your patience You are all very helpful!
    Attached Files Attached Files
    Last edited by ymmotteov; 12-01-2018 at 05:37 PM.

  11. #11
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Spinbutton to cycle through named ranges

    the list of range names you created is on a new sheet "range names"
    created new named CONSTANTS for the table header columns. For instance Opdracht=1
    Cell M1 is the linked cell for the spin button

    Blad1, A1:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    05-11-2017
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    22

    Re: Spinbutton to cycle through named ranges

    That is how it should work. But when I change the time in one of the ranges. The macro for the sorting gives an error message...

  13. #13
    Registered User
    Join Date
    05-11-2017
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    22

    Re: Spinbutton to cycle through named ranges

    Ok, I've made a few changes and it works!

    Learned something new again, thanks for the lesson! ;-)

  14. #14
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Spinbutton to cycle through named ranges

    You're welcome

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy values of all named range in wb1 to identically named ranges in wb2
    By JAMIAM in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-24-2016, 06:58 PM
  2. [SOLVED] VBA creates named ranges, but named ranges disappear
    By BrotherNeptune in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-05-2015, 03:22 PM
  3. Refer to named SpinButton in VBA
    By mjj300 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-06-2015, 08:15 AM
  4. Define only 2 named ranges from a list of named ranges...
    By abhi900 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-29-2014, 04:20 AM
  5. Looping Mutliple Named Resized Ranges in next empty row below another named range
    By gingumdog in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-19-2014, 08:15 PM
  6. Cycle Through Sheets & Sorting Named Ranges
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-12-2012, 09:53 PM
  7. macro to cycle through randomly named worksheet in workbook
    By benji* in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-25-2011, 05:15 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1