+ Reply to Thread
Results 1 to 4 of 4

Userform VBA only works when used on particular pages?

  1. #1
    Forum Contributor
    Join Date
    04-22-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    329

    Userform VBA only works when used on particular pages?

    Hi all,

    I'm almost there, I have a stock inventory with one particular UserForm that updates the register when ordered stock is received. The code updates received & amounts outstanding (if full order has not been received), it also updates "In Stock" to the relevant Supplier inventory page. Now the code works perfectly but only if the UserForm is run on that particular page e.g. amounts received & oustanding work perfect when UserForm is used on the "Orders" page, but goes haywire when used on the "Start" page? Likewise the instock update part of the code works perfect when the UserForm is used on the particular Suppliers page but goes haywire when used on the start page? Ultimately the UserForm should be opened on the start page but i'm at a complete loss as to why the code won't work? Sample attached, as always any help would be massively appreciated - Marco
    Attached Files Attached Files

  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: Userform VBA only works when used on particular pages?

    The usual reason for this behaviour is if your code does not fully qualify a range by prefacing the range with a worksheet reference.

    There's rather a lot of code and it's not clear which bit of code you are referring to. If you can be a bit more explicit then maybe we can help further.
    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
    Forum Contributor
    Join Date
    04-22-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    329

    Re: Userform VBA only works when used on particular pages?

    Please Login or Register  to view this content.
    Sheet4 is the “Orders” page, column “K” is a counter to give each order line a unique number to make search easier, this is the “Product9.Value”.
    Please Login or Register  to view this content.
    If “Product9” is blank do nothing
    Please Login or Register  to view this content.
    Finds the Row with the “Product9” counter value & pastes “Product7” value (Amount Received) plus the value already received in the Tracker column (column 12) this code works perfect if the userform is open up on the Orders page.

    Next
    Please Login or Register  to view this content.
    This code changes the active sheet to “Product1 value” (Supplier) e.g. “Allfix” or “3 Monkeez”.
    Please Login or Register  to view this content.
    To find the correct row we now find “Product3 value from the UserForm, this is the “Our Code” column on the active Suppliers page
    Please Login or Register  to view this content.
    Finds the Row with the correct “Our Code” value & pastes Product7 value to the in-stock column but also adds what was already in stock also so the stock value is exact. Next line puts what is still outstanding on the order into the “On Order” column. Again, this code works perfect when the userform is opened up on the supplier page. I need all the above to work from the “Start” page, hope this helps Richard? Thanks again - Marco

  4. #4
    Forum Contributor
    Join Date
    04-22-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    329

    Re: Userform VBA only works when used on particular pages?

    Update: Hi Richard, studied your initial comment of "your code does not fully qualify a range" & revisited, finally got it to work by activating each sheet just before that section of code ran, now working perfectly, see below, thanks for the push ok
    Please Login or Register  to view this content.

+ 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. Need vba code to print specific pages or all pages in a multipage UserForm
    By Pimp_mentality in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-24-2020, 08:13 PM
  2. [SOLVED] Userform Initialize (sometimes works, sometimes don't!)
    By Rajeshkumar R in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-18-2017, 01:57 PM
  3. [SOLVED] Userform initialize (sometimes works, sometimes don't!)
    By pepito_child in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-04-2016, 02:10 AM
  4. Replies: 0
    Last Post: 07-30-2014, 11:25 AM
  5. [SOLVED] Multiple pages in Userform
    By anthony_91 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-02-2013, 07:32 AM
  6. userform only works on my PC
    By Canuckbulldog in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-22-2007, 08:40 AM
  7. Pages on userform
    By Greg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-14-2005, 09:05 PM

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