Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default select visible cells when printing

have worked it out, no worries

change the 9 in Range(MyStart, MyEnd(1, 9)).Select to 35

R

-----Original Message-----
I have a spreadsheet that is sorted by column "AF". I

have
written a macro that prints each section sorted by column
AF. In the first part of the macro I have hidden some
columns that i don't want printed but when then data is
selected i.e. the first nine visible columns the macro
only goes up to way the hidden cells start and no

further.
Please help. Below is the macro I have written.

Private Sub CommandButton1_Click()

Application.ScreenUpdating = True

Columns("A:DZ").EntireColumn.Hidden = False

Columns("B:B").EntireColumn.Hidden = True
Columns("D:K").EntireColumn.Hidden = True
Columns("N:Q").EntireColumn.Hidden = True

Rows("1:1000").EntireRow.Hidden = False

Range("AF2").End(xlDown).Select

lastrow = ActiveCell.Row

Range("AF3").Select

For a = 1 To lastrow - 1

ActiveCell.Offset(0, -31).Select

Set MyStart = Selection
ActiveCell.Offset(0, 31).Select

Mynumber = ActiveCell.Value
Set Myloc = Selection

Do Until ActiveCell.Offset(1, 0).Value < Mynumber
ActiveCell.Offset(1, 0).Select
Loop

ActiveCell.Offset(0, -31).Select

Set MyEnd = Selection

Range("A1").Select
ActiveCell.FormulaR1C1 = "=vlookup(" & Mynumber & ",Table!
C:C[1],2,0)"
myheader = ActiveCell.Value
ActiveCell.ClearContents

'Change the 9 to represent the numberof columns on the
data sheet

Range(MyStart, MyEnd(1, 9)).Select

With ActiveSheet.PageSetup
.PrintTitleRows = "$2:$2"
.CenterHeader = myheader
.LeftHeader = "Portfolio"
End With

Selection.PrintOut copies:=1, collate:=True
MyEnd.Offset(1, 31).Select

If ActiveCell.Value = "" Then a = lastrow
Next a

End Sub
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can you select visible cells only by default, without Ctrl+G. Lucian Cornea Excel Discussion (Misc queries) 3 April 23rd 08 05:07 PM
select only used rows and only visible cells Rokuro kubi Excel Discussion (Misc queries) 2 September 28th 06 02:06 PM
When creating a formula how do you select only visible cells fuadramsey Excel Discussion (Misc queries) 1 June 13th 06 01:35 AM
how do I select, cut, and paste visible cells only Cutting and pasting invisible cells. Excel Discussion (Misc queries) 2 May 10th 06 09:55 PM
Select Visible Cells Only Apparently Excel Discussion (Misc queries) 2 January 29th 05 12:40 AM


All times are GMT +1. The time now is 04:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"