• Answers
  • Web
Personalize Yedda, (And make Danny Happy)
People ask & answer about almost everything. Tell us what you're interested in... So we can personalize Yedda especially for you
I'm interested in:

VB script for Excel spreadsheet printing

I wish to write a vba script I can run for a spreadsheet in MS Excel that only prints only the rows for a column (let's say columnd) where the cells are not null (or zero).

 The reason for this is that the rows total more than 100, and printing things out for only 20 actually needed entries seem silly.

Before anyone asks, MS Access is not an option. 

 

 


Share Send to a friend Watch Report
 

Best Answer

 
258 helpful answers

Ok, I really stumbled on this one.

 A friend got me through the hurdle.  And walked me through it.

So here goes.  Design the button, edit the code for it

here's the code for mine

rivate Sub CommandButton1_Click()

    Dim i, j As Integer

    ActiveSheet.Unprotect
   
    i = 2
    j = 2
    Do
       
        Do While Cells(j, 15) = "" And Cells(j, 1) <> "ENDOFLIST"
            j = j + 1
        Loop
               
        If j > i Then
            Range("A" & i & ":P" & j).Select
            Selection.EntireRow.Hidden = True
        End If
        i = j
       
        Do While Cells(j, 15) <> "" And Cells(j, 1) <> "ENDOFLIST"
            j = j + 1
        Loop
       
        Range("A" & i & ":P" & j).Select
        Selection.EntireRow.Hidden = False
        i = j
     
    Loop Until Cells(i, 1) = "ENDOFLIST"
   
    ActiveSheet.PageSetup.PrintArea = "$A$1:$p$" & i
    ActiveWindow.SelectedSheets.PrintPreview
 
    Range("A1:P" & i).Select
    Selection.EntireRow.Hidden = False
   
 
End Sub

'it's dynamic to the active sheet, so wow I really was impressed with the simplicity of it. 

Posted 2008-04-15T16:05:34Z
Helpful?(2)
Rated as Best Answer

 

Sign in to participate

Got an answer for JtotheA? Would you like to comment on the posted answers, or vote for the one which you think is the best?

Sign up for a free account, or sign in (if you're already a member).

Explore Related Questions

Other people asked questions on similar topics, check out the answers they received:


Q:

Sample Succession PLans in Excel FOrmat

Does anyone have ideas for excel sheet for succesion plans?
Submitted by careymm   4 months ago.
  • viewed 174 times


Q:

Tabs in MS Excel

Is there a way to display multiple tabs in MS Excel over two or more rows? I have many tabs and switching between them, while not ...
Submitted by drabsv   3 years ago.
  • viewed 1765 times
Last answer posted 3 years ago by EscApe


Q:

MS Excel 2007 Beta 2 - draw borders

Might be stupid but I can't find the "draw border" buttons on MS Excel 2007 Beta 2.
Submitted by drabsv   3 years ago.
  • viewed 1327 times
Last answer posted 3 years ago by drabsv



» More...

Explore Related Posts in Forums

Visual Basic 2008 Send a formula array to excel that requires {CNTRL} {SHIFT...

I am trying to enter the following on an excel spread sheet from vb.net: applic.activesheet.cells and the send keystrokes to excel then you need to set the value or formula and i believe in order to send the keys to excel it needs to have focus. sending keys is not something you can send as string as john

Extracting VBA from a Excel spreadsheet

Is there a clean way to extract the VBA from a spreadsheet and store it in a repository . The spreadsheets hardly ever change but the VBA does. Storing the whole spreadsheet in the repository... with Documents and VBA Code Using the Visual SourceSafe Add-In with the Visual Basic Environment...

VBA from .NET - Visual Basic .NET

I do a lot of using VBA from Access to create Excel spreadsheets and Word documents with lots There are a few articles on calling Macros, creating Excel spreadsheets, graphs etc here: http ...[color=blue] > There are a few articles on calling Macros, creating Excel spreadsheets, &gt
» More...
Powered by
Feed - Subscribe to changes to this Q&A Blog
ADVERTISEMENT
  • Answers
  • Web
Copyright © 2006-2009, Yedda Inc. and respective copyright owners · CC License