Print macro for Excel 2003.

  • Thread starter Thread starter Johan
  • Start date Start date
J

Johan

Hi,

I would like to create a macro that print my excel
worksheet from row 1 to a value in a certain cell. How do
I do that?

/Johan
 
The following should get you started:

Dim N
Dim cell As Range
N = Application.InputBox("Enter a value")
If TypeName(N) = "Boolean" Then Exit Sub
Columns("D:D").Select
Set cell = Columns("d:d").Find(What:=N, LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
If cell Is Nothing Then
MsgBox "No value found"
Else
ActiveSheet.PageSetup.PrintArea = Range(Range("a1"), cell).Address
End If

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top