+ Reply to Thread
Results 1 to 14 of 14

Generating report vba

  1. #1
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Generating report vba

    Hi all,
    I am using this code and it works fine.
    I want to modify it as follows and something is not right. Need your help please.
    Sample attached
    Many thanks
    Kind regards
    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Generating report vba

    Do you mean?

    Please Login or Register  to view this content.
    Last edited by AB33; 07-10-2014 at 06:45 AM.

  3. #3
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Re: Generating report vba

    Thanks AB33 .
    That works. Great.
    But any suggestions on reading data from sheets 1 to 8 only .
    Currently due to the line below it reads all and if I include another sheet it stops working.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  4. #4
    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,428

    Re: Generating report vba

    Try:

    Please Login or Register  to view this content.

    This just checks Sheets 1 to 5 as that's all that exist in this workbook


    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


  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Generating report vba

    KK1234,
    You could use sheets count from 1 to 8, but this is not good idea. You could use either array, i.e. you can put in all sheet names in array, or better is if the sheet names have some similarity or pattern where you can include or exclude one or more sheets

  6. #6
    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,428

    Re: Generating report vba

    You could use either array

    I did that ...

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Generating report vba

    Hi Trevor,
    I was typing and did not see your reply

  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,428

    Re: Generating report vba

    s'OK, no problem, just sayin',

  9. #9
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Re: Generating report vba

    Hi,
    I think I am blessed by both Gurus.
    Lucky me.
    AB33 and TMS it has been a great help form you. It works perfect
    Great thanks from me.
    Just one more question.
    In original sample book posted I am also planning to insert page breaks after last row copied from any sheet.
    Do you think it is possible please.
    I will close this thread after I get reply.
    Thanks again
    Kind regards

  10. #10
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Re: Generating report vba

    Something like
    Please Login or Register  to view this content.

  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,428

    Re: Generating report vba

    Please Login or Register  to view this content.

    Regards, TMS

  12. #12
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Re: Generating report vba

    What an EXPERT solution TMS.
    Great work.
    I am studying your code now to understand it and learn.
    That's the main line I was struggling with.
    Please Login or Register  to view this content.
    Thanks again

  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,428

    Re: Generating report vba

    Well, the full stop/dot (.) links the HPageBreaks to the ws referred to previously in the line "With ws", so it's applying the Horizontal Page Break to the ws worksheet.

    You have to tell it where to add the Page Break and you do that by referring to a range and the break is inserted BEFORE that range. lNR is just my shorthand for a long variable which holds the Next Row number. And lNR is determined in the line of code before and is based on the number of cells in column A.

    And, confusingly, it is a Horizontal Page Break because it goes across the page, hence, horizontally, although it is effectively splitting the page vertically.

    Hope that clarifies that line of code and how and why it is used.

    Regards, TMS

  14. #14
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Re: Generating report vba

    Thanks TMS.
    It is a great learning for me.
    Very well explained.
    Thanks again.
    Kind regards

  15. #15
    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,428

    Re: Generating report vba

    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. [SOLVED] Generating Report Numbers
    By alexander.small in forum Excel General
    Replies: 3
    Last Post: 11-26-2013, 12:02 PM
  2. Generating A Report??
    By GazNicki in forum Excel General
    Replies: 2
    Last Post: 11-30-2010, 09:28 AM
  3. Generating commission report
    By birdoo2 in forum Excel General
    Replies: 2
    Last Post: 04-11-2010, 11:08 PM
  4. generating report in excel
    By ramchalla in forum Excel General
    Replies: 0
    Last Post: 05-14-2009, 02:34 AM
  5. [SOLVED] Generating a report
    By JerryS in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-09-2006, 12:50 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