Hi anyone,
How could I write a code that would print all the visible rows and columns of the table.
My table has headers in row 10 of sheet "report".
It has data from column B to L. (column B is a hidden column).
I have data in row 7 also which is not part of the table but which still I want to print with the table.
Any help on this would be kindly appreciated.
Thanks in advance.
Print Table
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Print Table
See if this does what you need.
Hidden rows do not print, so there is no need to determine what is hidden or not.
Hidden rows do not print, so there is no need to determine what is hidden or not.
Code: Select all
Sub PrintCustom()
Dim rg As Range
Set rg = Range("C10").CurrentRegion.Offset(-3).Resize(Range("C10").CurrentRegion.Rows.Count + 3)
rg.PrintPreview '<< Change to rg.PrintOut if you want to print immediately
End Sub
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- SilverLounger
- Posts: 2347
- Joined: 23 Feb 2010, 12:07
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Print Table
Change the sheet name where indicated...
Code: Select all
Sub PrintCustom()
Dim sh As Worksheet
Dim rg As Range
Const shName = "Test" '<< Change sheet name here...
Set sh = Worksheets(shName)
Set rg = sh.Range("C10").CurrentRegion.Offset(-3).Resize(sh.Range("C10").CurrentRegion.Rows.Count + 3)
rg.PrintPreview '<< Change to rg.PrintOut if you want to print immediately
End Sub
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- SilverLounger
- Posts: 2347
- Joined: 23 Feb 2010, 12:07