+ Reply to Thread
Results 1 to 14 of 14

condense VBA

  1. #1
    Registered User
    Join Date
    01-08-2014
    Location
    wigan
    MS-Off Ver
    2007
    Posts
    78

    condense VBA

    Hi, is there a way of making the following more efficient:

    Basically, I am exporting a selection of pages from a workbook. THe selection is determined by the following
    Please Login or Register  to view this content.
    The value in B47 will either be a 0,1,2

    2 - selects minimum range, plus two additional sheets
    1 - selects minimum range, plus one additional sheet
    0 - selects minimum range only.

    the code is:

    Please Login or Register  to view this content.
    after which point a pdf is generated.

    as always thank you in advance.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: condense VBA

    You can start with
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,440

    Re: condense VBA

    Maybe:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: condense VBA

    Then next step could be:
    Please Login or Register  to view this content.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,440

    Re: condense VBA

    @Kaper: that's neat. Do you need a Case Else for the "0" option?

    And the double post is the forum, not you. Report the post to get it removed as a" forum induced double post"

    Regards, TMS

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: condense VBA

    Hi,

    Thanks for advice with double post.

    As for case 0 (or case else) - I do not think is needed.
    initial value of sheetsstring has already all needed sheet names.
    Something has to be added to this string only in case 1 or 2.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: condense VBA

    I would write like this.
    Please Login or Register  to view this content.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,440

    Re: condense VBA

    So, if x=2, you would reduce the upper bound by 2 ... . Feels wrong but I might be missing something.

    I like the concept but maybe it should be -(2-x)

    Regards, TMS

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: condense VBA

    Ahhh, it was other way around... thanks.

    Perhaps
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    01-08-2014
    Location
    wigan
    MS-Off Ver
    2007
    Posts
    78

    Re: condense VBA

    Hi, sorry for the delay - I have been away for a week.

    Can I please ask - if I needed to include an additional worksheet at the end of
    Please Login or Register  to view this content.
    based on the same criteria how would I go about that?

    I have tried

    Please Login or Register  to view this content.
    but this does not work.

    thanks.
    dan.

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,440

    Re: condense VBA

    Well, the Director sheets are the optional ones, so they have to stay at the end.

    Stick it in the middle somewhere before those Director items. I guess where depends on the sequence you want them printed.

    Regards, TMS

  12. #12
    Registered User
    Join Date
    01-08-2014
    Location
    wigan
    MS-Off Ver
    2007
    Posts
    78

    Re: condense VBA

    Hi,

    The additional pages would also be optional. So if either director has a tax projection then i would also want to show the calculation at the end

    thanks.

  13. #13
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,440

    Re: condense VBA

    Then you need to look at your OP and adapt the code to reflect another variation.

    The value in B47 will either be a 0,1,2

    2 - selects minimum range, plus two additional sheets
    1 - selects minimum range, plus one additional sheet
    0 - selects minimum range only.

    Regards, TMS

  14. #14
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: condense VBA

    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. Condense Information
    By ace2go in forum Excel General
    Replies: 14
    Last Post: 07-12-2013, 11:06 AM
  2. Condense Data
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-10-2011, 04:02 PM
  3. Condense code
    By tone640 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-02-2011, 08:25 AM
  4. [SOLVED] Condense Code
    By Nigel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-22-2005, 08:10 PM
  5. [SOLVED] Condense formula
    By Derek Y via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-17-2005, 11:10 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