Hi,
have the code below can I change it to:
1. Add total of printed
2. to print only due dates (select due date range) instead
thanks.Please Login or Register to view this content.
Hi,
have the code below can I change it to:
1. Add total of printed
2. to print only due dates (select due date range) instead
thanks.Please Login or Register to view this content.
Dude. This has been viewed over 400 times, but no answers. We need to see a bit more of your workbook and code to be able to offer any help.
If you have a look at the yellow band at the top of the page it'll explain how to post a (cut-down, desensitised) version of your workbook so we can look into helping you.
Tim
Never stop learning!
<--- please consider *-ing !
Attached sample file.
thank you
Any help, please?
If you make the minor changes (below) the sub will just print out what's visible. That means you can use the Status and Past Due etc buttons to do the filtering, and just print-preview the table holding those data.Was that the intention? I'm not sure what you mean by "Add total of printed". You could display the "totals" row in the table and include that in your print, but unfortunately, non-contiguous ranges always print on separate pages, so it won't make for a neat and tidy print-out.Please Login or Register to view this content.
Tim
Last edited by harrisonland; 04-13-2020 at 10:39 PM.
Hi,
I tried but only print first row and there's more than one row visible.
and for the total to add total amount of visible amounts.
thanks,
Have you "PageDown'ed"? Non-contiguous ranges show on separate pages - and it seemed to work when I tried it before posting.
On the attached, hit "Past Due Age" 1-30 days, then hit "Print Dues". My result is 2 pages (was three, but I tweaked it) Page 1 is the data range, Page 2 the totals row.
Tim
Hi,
I tried in workbook works but in mine give me run-time eror 5Attachment 672551 when press debug highlight this line:
code below:Please Login or Register to view this content.
ThanksPlease Login or Register to view this content.
Hi,
think the error is because ofgive me error label no defined and if I remove that line and addPlease Login or Register to view this content.
then prints preview fine but when close get error 91.Please Login or Register to view this content.
sorry to bother but I am new vba.
thanks
Duh... sorry, my bad. Had another look and improved. Should be this:This also fixes the issue with it printing on multiple sheets (I've no idea why I didn't realise what was happening before!)Please Login or Register to view this content.
I'll re-upload the attachment here.
Tim
NB forgot to say, you could make the print visually larger if you don't need all the columns in the table to be printed. E.g. instead of just generating the print preview, you could do this instead:Only you can decide what you need, but hiding columns while forcing the print into one sheet wide will certainly make the writing clearer.Please Login or Register to view this content.
Tim
thank you so much worked perfectly.
is it possible to add subtotal function in the code instead, and no in the spreadsheet because need to add more records and and will not let me cause of subtotal formula.
Thanks again.
Calculating the subtotal separately would be a pain. You'd have to copy the data to be printed to a separate, temporary worksheet, insert the calculations, set columns widths and print range, print that sheet and then delete it. You could, of course, set up a print template for that purpose and leave it sat there. If you create totals using "=sum(Ax:Ay)" it will count add all values, not just those visible.
Personally, I'd keep it simple and use one of these methods to insert new rows into the table and let the worksheet do everything else itself:
- Hit [TAB] from the last cell in the data range of the table (J37 in the sample you provided)
- Right-click any cell in the table and hit "Insert" -> Insert table row. It'll be sorted later anyway.
- Grab the little green corner of the table (bottom right of the Totals row in column J) and drag it down however many new rows you need.
Tim
Hi Tim,
I tried your suggestion about totals and entered formula =SUBTOTAL(109,[INVOICE AMOUNT]) but I am getting this error (attaching picture)
any suggestion?
thanks
Sorry, I've absolutely no idea what that means because I have absolutely no context for that formula. Anyway...
I've created a print template in the attached file and linked the print button to it. Obviously the print template could then be hidden (or xlVeryHidden to hinder meddling) after you've set it up the way you like it.
The print range is simply the table, but you'll see in the VBA code you can enter headers and/or footers for the print too. I suppose you could adjust the print area to include row(s) above the table and put a title or whatever there, too. Study the code so you know what's going on and how to adapt it!
Tim
thank you, Very much.
worked excellent!
the only las question i have is how do I hide the template by usinghave no idea no that good in vba.Please Login or Register to view this content.
thanks.
You have to do it either manually in the VBA environment, or in code.
Open up the VBE and hit F4 (I think) to bring up the Properties page if it's not already visible. Select the worksheet, and change the Visibility to xlVeryHidden. Then it can't be unhidden without accessing the VBE.
Tim
Last edited by harrisonland; 04-20-2020 at 01:43 PM.
Tried give an error.
is there any way in the print code to unhide the sheet when click print and hide it back when previewing it.
thanks.
I'll have a look when I get home. It'll be easier than faffing about on the phone.
Tim
thank you.
Right. It won't generate the print preview while the print template worksheet is not visible, so we'll just unhide it to do the print preview, then hide it again afterwards.
See the attached.
Tim
Hi Tim.
worked good the only problem prints ok first time, once you filter and filter another range will ask if it want to overwrite and said yes the total formula is gone.
Thanks.
Hi again. Sorry, but I wasn't able to replicate that behaviour; filtering, and re-filtering seemed to work OK, printing completed as expected and the print template was cleared of data ready for the next print.The above clears the data from the print template and resizes the table, but it doesn't touch the totals row at the bottom.Please Login or Register to view this content.
If you're referring to the totals row on the "Invoices" worksheet, I had removed it as I thought you didn't want it to show as this would make it easier to add extra data at the bottom. You can make it visible again by right-clicking anywhere in the table, selecting "Table" then "Totals Row".
Tim
Hi Tim,
it's weird it worked couple times but once it ask to overwrite the totals are gone,
no sure if the line you gave me to clear the data I put the in the wrong spot, here is the code:
Please Login or Register to view this content.
Nah, those lines are already in the code so you don't need to add them.
I still can't replicate the problem, even though I've been round and round filtering, generating print, clearing... doing the same without clearing filters etc.etc.etc... (Just to be clear, I'm running the "test()" sub in module 2.)
I'd suggest you run the macro manually - step by step, using F8. Then you'll be able to see the effect each step is having in the workbook. Remember to make the print template visible to start with and maybe comment out the line that hides it.
Tim
Hi Tim,
I tried F8 step by step and think found out what's the problem was looks now it's working
What I did enable the this line back because it was comment out and clears all format no the formulas i filtered list few times and still works.
line that was commented out and enable back:
Thanks so much for all your time and help, much appreciated.Please Login or Register to view this content.
Hi there. Sorry, I've been away for a few days. Glad you got it sorted.
Tim
If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
Ali
Enthusiastic self-taught user of MS Excel who's always learning!
Don't forget to say "thank you" in your thread to anyone who has offered you help.
You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.
Forum Rules (updated August 2023): please read them here.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks