I have pulled the data into Sheet3 from Sheet1 using excel formulae.Sheet1 Contains Provision for Names in Range A2:A52 (Provision fior 50 Names). Sheet3 has about 50 pages Formated depending on the data in Sheet1. Every Page in Sheet3 has same format with 29 Rows and 26 Columns. If there are only 30 Names in Sheet1, then the data in Sheet3 for the balance 20 are blank or zero.
Every page in Sheet3 has a link formula to abstract the name from Sheet1.Intersection of Row 3 and Column 16 in Every Pagen in Sheet 3 has the Name abstracted from Sheet1. If Sheet1 has no Name, this Row3 and Column 16 has Zero Value.
My problem is How can I use VBA in Excel 2007 to Print only those Ranges (Row1 to Column16) in Every Page in Sheet3 In Which the Cell Value (Row3,Column16) is Not Zero. How can I use a Command Button in Sheet3 to accomplish this task.
loknath
Printing Specific Range based on Cell Value
-
-
-
Re: Printing Specific Range based on Cell Value
I dont fully understand your question, and your talk of "pages" on sheet 3.
But basically, you ned to set a range variable to whatever it is you want to print and use the "printout" method. You can also test the value of a cell like you see the code below. This will probably not work for you, you will need to adapt it for your own usage.
Code
Display MoreSub printout() Dim r As Range Set r = Worksheets(3).Range("A2:P52") If Trim(Worksheets(3).Cells(3, 16).Value) <> "" Then r.printout End If End Sub
Sorry I couldnt be of more help... rather busy in work.
Ger
-
Re: Printing Specific Range based on Cell Value
Hi Ger,
Thanks for your comment and the help. To be specific I have a worksheet (Sheet3) in which there are about 100 Pages . In each page in Sheet3, the Intersection of Row3,Column16 has a cell value (Name of a person). This name is linked to name in sheet1. So, what i want is that I want to print only those Pages in Sheet3 where the Intersection of Row3,Column16 (In Each Page) has a cell value (Name of a person). I don't want to Print from Page 32 and below as the Cell Row3,Column16 in Page 47 is Blank. I want to Use a UserForm to Select the Names from the list and Print Pages for all the Names or Specific Names based on Selection from the ComboBox.
Thanks
Loknath
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!