Select and Print Only Cells with Values

Adman

New Member
Joined
Nov 13, 2019
Messages
3
Hi, newbie to VBA here. I have been researching and trying many ways to select and print a range, and I cannot find a way to print cells with values only.

In my case, I create a list of entries through the day. I am creating a button so I can print all of these entries at the end of the day.

These entries are sorted by column, and I will only be printing one column at a time.

The code that I have tried that isn't working is below. I realize that I am not using the "End" in its proper syntax. It was a futile effort after trying many other ways to code it in.

Code:
Sub Button1_Click()ActiveSheet.PageSetup.PrintArea = Range(A5, End(xlDown))
ActiveWindow.SelectedSheets.PrintOut ' print


End Sub

Any help in getting this up and running is much appreciated!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
I'm not great with VBA myself, but have you tried switching "SelectedSheets" from line 2 into just "Selection"? First thing I noticed.

I've done it where I've had VBA select what I wanted, copy/paste it onto a new sheet, print, and then have the macro delete the spreadsheet in all one motion as well. I could help with that, though I'm sure the experts here have a more elegant solution
 
Upvote 0
I'm not great with VBA myself, but have you tried switching "SelectedSheets" from line 2 into just "Selection"? First thing I noticed.

I've done it where I've had VBA select what I wanted, copy/paste it onto a new sheet, print, and then have the macro delete the spreadsheet in all one motion as well. I could help with that, though I'm sure the experts here have a more elegant solution

Thanks for your reply! I'm hoping to get a more concise line of code for this function so I can learn to work better within VBA.
 
Upvote 0
Hi & welcome to MrExcel.
How about
Code:
Sub Button1_Click()
ActiveSheet.PageSetup.PrintArea = Range("A5", Range("A5").End(xlDown)).Address
ActiveSheet.PrintOut ' print
End Sub
 
Upvote 0
Thank you for the suggestion! That's exactly what I was looking for.

The code I have created that works for me:

Code:
Sub Butt*******1()ActiveSheet.PageSetup.PrintArea = Range("A5", Range("A5").End(xlDown)).Address
ActiveWindow.SelectedSheets.PrintOut ' print
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,702
Messages
6,173,961
Members
452,539
Latest member
delvey

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top