Need VBA code to print cells

biggmann

New Member
Joined
Oct 29, 2011
Messages
8
I am working on a excel project for work that is a schedule of jobs for the week. I have VBA code to add a new job and thanks to help on here I now have a button to delete completed jobs. My last problem is I want to have a button to print rows that only have data in them or only print certain cells say the first couple cells that have specific detail about the job. I know that it would be easy to do with a sort or filter but this is for a office that the ones that will be using this aren't that Excel literate so I am trying to make it as easy as possible to use that is why the print button. I have hacked together a bit of code that not surprisingly doesn't work. I have a sheet called Schedule and I want to print columns A to H and only print the rows that contain data not the empty rows. I know this code isnt correct but I am grasping at straws here so any help would be greatly appreciated.

Code:
Sub Rectangle4_Click()
With Application
.ScreenUpdating = False
.DisplayAlerts = False
ThisWorkbook.VBProject.VBComponents("Schedule").Export "test.txt"
Workbooks.OpenText "test.txt"
With ActiveSheet
.Cells.Font.Name = "Courier"
.PageSetup.LeftMargin = Application.InchesToPoints(1)
.Cells.PrintOut
End With
ActiveWorkbook.Close
Kill "test.txt"
.DisplayAlerts = True
.ScreenUpdating = True
End With
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
This code may be usefull

Code:
    Columns("A:H").Select
    Selection.PrintOut Copies:=1

The first line "selects" the columns you want to print.
The Second line prints the used range in the "selected" columns
 
Upvote 0

Forum statistics

Threads
1,225,761
Messages
6,186,894
Members
453,383
Latest member
SSXP

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