+ Reply to Thread
Results 1 to 14 of 14

Macro hides the wrong rows and is too slow

  1. #1
    Registered User
    Join Date
    03-13-2013
    Location
    Wichita,KS
    MS-Off Ver
    365 Aps for Enterprise
    Posts
    60

    Macro hides the wrong rows and is too slow

    Here is my current macro:

    Please Login or Register  to view this content.
    First of all, when I click on the "Quote" tab there is some delay which I believe is due to the macro. Is there anything I can do to speed this up?

    Secondly, I do not understand the above macro and how it works though I have spent countless hours trying to find something in this and other forums. I'm not sure if the macro hides or unhides rows. The user needs to be able to insert or delete rows ABOVE the hidden (or unhidden) rows without changing the range of hidden rows.

    On the "Calculation" sheet, Rows 38-66, the user may select options by entering a quantity in Row A.

    Attachment 313847

    Then when the user clicks on the "Quote" sheet only the rows with the options that the user selected are visible.

    Attachment 313852

    In an Excel spreadsheet I would just use the dollar sign ($) to indicate absolute reference and be done with it but I don't understand how "B & i" refers to a specific range of rows. Is "B" the column and "i" the row? Also, I would like the "Available Options" row (on Quote sheet) to be visible only if the user has selected at least one option on the "Calculation" sheet.


    Thanks for your help in helping me understand this.
    Marvin
    Attached Files Attached Files
    Last edited by Marvelous; 04-24-2014 at 05:07 PM. Reason: Add attachment - worksheet

  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: Macro hides the wrong rows and is too slow

    I think we need to go back to basics and for you to upload the workbook and explain your process. i.e. how you use the sheet and what you expect to happen when various actions take place. Manually add some calculated results, explain where they are and what rules have been applied in deriving the results.

    Re your absolute Q.
    B & i doesn't refer to a range of cells, only the single cell Bi where i is an integer starting at 45 and incrementing by one each time through the loop until the macro finds a blank cell below B45.

    You probably don't want an absolute address in the looping section of code, but in general the syntax would be "$B$" & i
    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-13-2013
    Location
    Wichita,KS
    MS-Off Ver
    365 Aps for Enterprise
    Posts
    60

    Re: Macro hides the wrong rows and is too slow

    Thanks for your response. I have edited my original post to include a worksheet that shows both the "Calculation" and the "Quote" sheet. Basically the user adds all of the standard items he wants and then selects all of the Options he wants on the "Calculation" sheet. The info is transferred over to a quote page on the "Quote" tab. This is a quoting file that I send out to several inexperienced Excel users. Two challenges that I am having:
    1) The user needs to add or delete rows above the "Available Options" section and this throws off which rows are visible.
    2) I cannot protect the sheet from hiding & unhiding because that is what the macro is doing but sometimes the user forgets and will manually unhide or hide some of the "Available Options" rows on the quote sheet. This seems to mess up the whole system.

    Thanks again for your help.
    Marvin

  4. #4
    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: Macro hides the wrong rows and is too slow

    Hi,

    Not quite sure I'm understanding this yet but here goes.
    Are you saying that the process is to mark various rows in the Calculation sheet with positive quantities, and then have those rows, and only those rows appear on the Quote sheet?

    If so then the simplest way is to just use a Data Filter in a macro. There would be no hidden rows on the Quote sheet, just the rows that have been identified on the Calculation sheet.

    Are the rows 1:42 on the Quote sheet and 1:36 on the Calculation sheet fixed and never changing?

  5. #5
    Registered User
    Join Date
    03-13-2013
    Location
    Wichita,KS
    MS-Off Ver
    365 Aps for Enterprise
    Posts
    60

    Re: Macro hides the wrong rows and is too slow

    I think the answer to your first question is yes but there are other rows of data (not options) on both sheets. This is rather difficult to explain so bear with me. The number of Options rows (29) will stay the same on the Calculation sheet but sometimes the user may customize the data.
    Also, some rows above and below the 29 Option rows may be added or deleted on both the "Calculation" and "Quote" Sheet. So in essence, the block of 29 Option rows may move up or down on both sheets.
    Does that answer your questions?

  6. #6
    Registered User
    Join Date
    03-13-2013
    Location
    Wichita,KS
    MS-Off Ver
    365 Aps for Enterprise
    Posts
    60

    Re: Macro hides the wrong rows and is too slow

    Richard,

    Did you see my response? Did it make sense?

    Thanks for your help.

  7. #7
    Registered User
    Join Date
    03-13-2013
    Location
    Wichita,KS
    MS-Off Ver
    365 Aps for Enterprise
    Posts
    60

    Re: Macro hides the wrong rows and is too slow

    Bump - no response

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro hides the wrong rows and is too slow

    Hi Marvelous

    Will your Options on Sheet Calculation ALWAYS start on Row 38?

    Will your Options on Sheet Quote ALWAYS start on Row 45?

    Will there ALWAYS be 29 Options on each Sheet?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  9. #9
    Registered User
    Join Date
    03-13-2013
    Location
    Wichita,KS
    MS-Off Ver
    365 Aps for Enterprise
    Posts
    60

    Re: Macro hides the wrong rows and is too slow

    Jaslake,

    Thank you for responding to my post. The Options on the Calculation sheet will always start at Row 38 and there will always be the same number of option rows. The Options on the Quote sheet will not always start at Row 45 because the user needs to be able to add or delete rows above. There will always be 29 option rows on the Calculation sheet and the same number on the Quote sheet (of course we are hiding the "unselected" rows/options on the Quote sheet). I hope this is a good explanation?

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro hides the wrong rows and is too slow

    Hi Marvelous

    Place this Code in Calculation Sheet Code Module
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    03-13-2013
    Location
    Wichita,KS
    MS-Off Ver
    365 Aps for Enterprise
    Posts
    60

    Re: Macro hides the wrong rows and is too slow

    Jaslake,

    This seems to work except when I delete a quantity out of the "B" Column on the Calculation sheet I get the following error: "Compile Error: Ambiguous name detected: Worksheet_Change."

    Any ideas.

    Thanks so much for your help!

  12. #12
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro hides the wrong rows and is too slow

    Hi Marvelous

    That error message would indicate you've two Macro Procedures with the same Name. Since the File you provided had no Code in it I can't troubleshoot without seeing your File...and...Column B does not come into play with the File you provided...so you have me a bit confused.

  13. #13
    Registered User
    Join Date
    03-13-2013
    Location
    Wichita,KS
    MS-Off Ver
    365 Aps for Enterprise
    Posts
    60

    Re: Macro hides the wrong rows and is too slow

    Jaslake,

    Here is the code that is in the Calculation sheet.

    Please Login or Register  to view this content.
    I'm pretty new with VBA so I'm not exactly sure where to put your code or what to change in order to stop this error. I just put your code below the existing macro and erased the "End Sub" above it.

    Please ignore the above comment about Column B, I meant to say Column A.

    Thanks for your continued assistance!

  14. #14
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro hides the wrong rows and is too slow

    Hi Marvelous

    I have no clue what the "Old" Code is doing...this Compiles and colors some Cells...try it, let me know. Replace BOTH Worksheet Change Event Codes with this.
    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. Clunky Slow Code, Hides Empty Rows, Takes too long...
    By BoSonic in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-18-2013, 08:56 PM
  2. I have Vlookup and autofill macro, its slow, what Im doing wrong?
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 02-06-2011, 10:18 PM
  3. User form hides wrong information
    By EGR2317 in forum Excel General
    Replies: 14
    Last Post: 05-28-2010, 01:46 PM
  4. How to make my macro delete rows? It currently hides the rows instead of deleting.
    By Majkataxmk in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-20-2010, 01:14 PM
  5. macro that hides rows run slow
    By yoav_b in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-15-2007, 11:16 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