Excel Help (OT??)

Yeah, I know. Excel is a computer program. However, I do use it in this instance for design, so bear with me.

I have a 20 sheet spreadsheet to do some phase locked loop stuff. Depending on what gets put on this or that page, there may or may not be calculations performed on other pages.

However, I have it so that IF a calculation is performed on a page, one particular cell (just for grins, let's call it cell F22) will have a value in it, otherwise it will be zero or empty.

Is there a way of selectively PRINTING pages that have a value other than null or zero in cell F22 and not printing those that have this cell empty?

Jim

--
"It is the mark of an educated mind to be able to entertain a thought 
without accepting it."
        --Aristotle
Reply to
RST Engineering (jw)
Loading thread data ...

Probably, if you're not afraid of VBA.

Good Luck! Rich

Reply to
Rich Grise

As Rich said - yes if you are ok with VBA. I have done a sample xls with three sheets with a zero, 1 and empty F22. If you load it and run (alt F8) the selprint macro you should get a print preview of only the sheet with the 1 in F22. I do not claim that this is the best way of doing the job. You can change the comments in the VBA routine to print the sheets without previewing each one. Here is the macro I created:-

Sub selprint() Dim i As Integer Dim currentsheet As Worksheet

For i = 1 To ActiveWorkbook.Worksheets.Count Set currentsheet = ActiveWorkbook.Worksheets(i) Worksheets(i).Activate 'Skip empty sheets and hidden sheets If Application.CountA(currentsheet.Cells) 0 And currentsheet.Visible Then 'change the hard-coded cell here if not F22 If (Not IsNull(Range("F22"))) And (Range("F22").Value 0) Then 'un-comment the next line when debugging completed ' ActiveSheet.PrintOut 'add comment at start of next line when debugging completed ActiveSheet.PrintPreview End If End If Next i End Sub

and the test xls file is available (for a short time) at

formatting link

HTH

Geo

Reply to
Geo

Geo ...

Thanks for your help. I have cut the subroutine you wrote and pasted it into a regular text document so that I could have it embedded into the document that I am working on.

I hate to bother you for more help, but the truth is that (for example) the page could actually have EITHER F22 OR G16 OR both filled if something else happened elsewhere. Is there an easy way of modifying the routine you wrote so that it would pick up the page no matter whether or not either or both of those cells were filled.

As to familiarity with VBA, I used to teach regular old Dartmouth (or Gee Whiz) Basic at the college level thirty years ago, but dropped out of the Basic picture when MS started making their Basic look a lot less like English and more and more like Assembly (which I detested). I've got a VBA text and can figure out what a particular routine does and sometimes why it does it that way, but as an accomplished VBA programmer, I ain't.

Thanks for your help again.

Jim

-- "It is the mark of an educated mind to be able to entertain a thought without accepting it." --Aristotle

Reply to
RST Engineering (jw)

Starts getting messier with more tests but taking your example, you coulde modify the line:- "If (Not IsNull(Range("F22"))) And (Range("F22").Value 0) Then" to include an OR function e.g. "If ((Not IsNull(Range("F22"))) And (Range("F22").Value 0)) or ((Not IsNull(Range("G16"))) And (Range("G16").Value 0))Then"

Alternatively could you use another cell on the sheets to flag that F22 OR G16 had a non-zero number? I am not an excel expert so you /could/ get a more structured response from a microsoft excel newsgroup. I also started with GW then QB the VBDOS 1.0 - stopped at VB6 when they went to .NET

Geo

Reply to
Geo

Of course, Geo. A simple IF-OR statement in an empty cell to set a particular value that I can use your original routine will work just fine.

Thanks,

Jim

Reply to
RST Engineering (jw)

You could have a cell other than those two, on each sheet, that has the checking routine for the two cells in question, and use the main routine to test the value of that one cell per sheet.

Reply to
Archimedes' Lever

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.