![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Posts: 422
|
I have 5 columns B to I in these I have either 1 or 0.5 I need a macro that that goes down to the last entry in any of these columns and selects the entry in I.
I am setting it up to create a print area A1 to the active cell I hope this is clear. |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Kissimmee, Florida
Posts: 384
|
The routine below will get to the last row.
There are actually 8 columns between B and I so I have assumed that you wanted all of these included in the search and included the code in the macro. *** Sub FindLastRow() Dim AmILast(8) Dim Biggest As Double Dim PrtRng As String Biggest = 0 For a = 1 To 8 Range("A65535").Offset(0, a).Select Selection.End(xlUp).Select AmILast(a) = ActiveCell.Row If AmILast(a) > Biggest Then Biggest = AmILast(a) Next PrtRng = "A1:I" & Biggest ' Range(PrtRng).Select ActiveSheet.PageSetup.PrintArea = PrtRng End Sub
__________________
Hope This Helps. Sean. Digest of Homes WinXP, XL XP |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Posts: 422
|
Thank you for your help I forgot I had 3 columns hidden I only need to find this data in columns B C G H I sorry if this is harder apart from that it was just what I wanted
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|