Macro basics
Dim iLastCol As Long
dim iLastRow as long
With Worksheets("2006 Realized Gains")
'you have to select the sheet before you can select a range
'but you don't have to select either to get your code to work
'.select
'.Cells.Select
.cells.EntireColumn.Hidden = False
.AutoFilterMode = False
iLastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
iLastRow = .cells(.rows.count,"A").end(xlup).row
application.goto _
reference:=.cells(ilastrow + 1, ilastcol) ',scroll:=true
end with
I used column A to find the nextrow (iLastRow + 1) to go to.
I don't understand the second question.
Dallman Ross wrote:
I'm trying to develop some macros. I'm not that versed
at it yet. Here is part of something:
Dim iLastCol As Long
With Worksheets("2006 Realized Gains")
Cells.Select
Selection.EntireColumn.Hidden = False
.AutoFilterMode = False
iLastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
Application.Goto Reference:= _
"INDEX(R1:R65536,COUNTA(C[1])-1,30)"
See that "30" in the last line? That's Column 30 ("AD"). I
tried to use my "iLastCol" variable instead, but could
not. I tried all sorts of permutations; still no luck.
What's the trick?
Seconds question: How can I save the Application.Goto Reference
for repeat use without inserting that statement again each time?
E.g., later I will want to select the row below that
row. How would I do that?
Thanks for any help.
Dallman Ross
--
Dave Peterson
|