+ Reply to Thread
Results 1 to 8 of 8

VBA Userform Next and Previous Buttons that work on current activesheet/open sheet

  1. #1
    Registered User
    Join Date
    03-19-2020
    Location
    South Korea
    MS-Off Ver
    excel 2016
    Posts
    6

    VBA Userform Next and Previous Buttons that work on current activesheet/open sheet

    I am new to coding in VBA but have been able to figure how to add next and previous buttons. The problem is they always go through the data in "Sheet1" and will not work on the other sheets after I activate them. I have a combobox that will activate a specific sheet but after I active a different sheet the next and previous buttons are still pulling data from the first sheet. What I want them to do is when I hit the next button it will cycle through the data on the activesheet. Any help is appreciated.

    The Code for the Next Button:
    Please Login or Register  to view this content.
    The code for the previous button is:

    Please Login or Register  to view this content.
    Last edited by pumashoes; 03-19-2020 at 08:27 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA Userform Next and Previous Buttons that work on current activesheet/open sheet

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    In addition uplod the workbook so that we may see therequest in context
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    03-19-2020
    Location
    South Korea
    MS-Off Ver
    excel 2016
    Posts
    6

    Re: VBA Userform Next and Previous Buttons that work on current activesheet/open sheet

    Thank you. I have updated

  4. #4
    Registered User
    Join Date
    03-19-2020
    Location
    South Korea
    MS-Off Ver
    excel 2016
    Posts
    6

    Re: VBA Userform Next and Previous Buttons that work on current activesheet/open sheet

    Attached is the form for review.
    Attached Files Attached Files

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA Userform Next and Previous Buttons that work on current activesheet/open sheet

    You'll have to talk me through this and how you use it in practice. It's rather a busy form
    When I load the form it is unpopulated, should the various boxes be filled in


    When you say you activate sheets how are you doing that? Via the userfrm or manually by selecting a different sheet.
    How do you load the Userform, via the Excel run macro menu or via a button?

    And when you talk about cycling through the data I presume you expect records from the database to appear in the form, but as I say above there is no data in the frm. How do you select the first record to populate the sheet. The various boxes don't appear to be drop downs which rather suggests you're manuall entering stuff and the prime purpose is to send new data back to the sheet database, hence as I say what does 'cycle through data' really mean.



    In essence though you should have a Sheet Variable that identifies a sheet and then fully quaify any reference to a range by prefacing it with the sheet variable

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: VBA Userform Next and Previous Buttons that work on current activesheet/open sheet

    Along with everything that Richard has said. The root cause is that in the LoadRow procedure you have
    Please Login or Register  to view this content.
    Which means it's always pulling info from sheet1(7AF-EDS) regardless of which sheet is active

  7. #7
    Registered User
    Join Date
    03-19-2020
    Location
    South Korea
    MS-Off Ver
    excel 2016
    Posts
    6

    Re: VBA Userform Next and Previous Buttons that work on current activesheet/open sheet

    Thank you for the help and assistance. I seem to have it working now based on the advice from you and Fluff13.

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: VBA Userform Next and Previous Buttons that work on current activesheet/open sheet

    Glad you sorted it & thanks for the feedback

+ 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. [SOLVED] Userform pulling data but Next and Previous buttons do not function - Any thoughts?
    By JJFletcher in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 06-19-2016, 09:20 AM
  2. [SOLVED] UserForm MultiForm and Command Buttons for next and previous tabs
    By DonJuan85 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-29-2015, 02:43 PM
  3. Re-code Userform to open range of sheets like previous sheet code
    By JJFletcher in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-15-2014, 02:31 AM
  4. [SOLVED] Display worksheet information on userform textbox Next & Previous buttons
    By hecgroups in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-14-2014, 12:50 PM
  5. [SOLVED] Userform Previous Next Buttons to Show Only Filtered Records?
    By cindy71 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-12-2012, 10:38 AM
  6. [SOLVED] UserForm to work on ActiveSheet
    By 55horses in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-18-2012, 10:26 AM
  7. How to change current syntax to have ActiveSheet.Previous.Select
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2012, 10:38 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