• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Creating a print command button and VBA code to print selected cells (various table in one worksheet)

Del79

New Member
Am a novice at VBA and appreciate advise on my problem.

I want to create multiple buttons where each button is linked to a specific table in a worksheet via VBA. When the button is clicked, it will automatically print the specified table. I have 3 tables in one worksheet. Tried to create different modules for each table to be linked to respective buttons via below code:

Code:
Sub PrintSomeCells()
Range("I1:V66").PrintOut                                     "I changed the range on this part per macro."
End Sub

1. I was able to create 3 modules and attach it to respective command buttons per table. When I tried to test print, it didn't print the range I specified for the button. Was there something wrong with my code or how I attached the macro?
2. Will the above code help to maintain the formatting of range cells to be printed?
3. Any other ideas on how I can go about this would be greatly appreciated.

Attaching a sample file. Have created the VBA for all 3 tables. Thanks in advance!
 

Attachments

  • Sample.xlsm
    21.6 KB · Views: 1
Last edited by a moderator:
Del79
One sample
... Your missed to tell Print Area
Thank you so much!!!! Just one more item please....how can I print one table in one page instead of 2 pages? What code should be added to the one you sent so it will just print the area into a single paper?
 
Del79
As You wrote ... Am a novice at VBA and ...
One hint ... some parts could do without VBA.
You could solve that same way as before ... with 'Page Setup'.
If You need hints about that ... then free to ask - okay?
 
OK! I will research, do some testings and if still don't work...will let you know. Super thank you!!!! Really a big help for me!
 
Last edited by a moderator:
Del79
As You wrote ... Am a novice at VBA and ...
One hint ... some parts could do without VBA.
You could solve that same way as before ... with 'Page Setup'.
If You need hints about that ... then free to ask - okay?
Hi vletm - thank you soooo much!!!!! I was able to do it!!
 
Back
Top