last record

G

geebee

hi,

i have the following:

Dim lastrecordAGING As Long
Range("AE5000").End(xlUp).Offset(0, 0).Select
lastrecordAGING = Selection.Row
Range("E2").End(xlToRight).Offset(0, 1).Select
Range(Selection, Selection.End(xlDown)).Select

i am trying to figure out how i can amend the lasdt line so that it only
selects up to the lastrecordAGING.

thanks in advance,
geebee
 
M

Mike H

Hi,

If I've understood correctly, try this:-

Sub stance()
Dim lastrecordAGING As Long
lastrecordAGING = Range("AE5000").End(xlUp).Offset(0, 0).Row
lastcell = Range("E2").End(xlToRight).Offset(0, 1).Address
Range(lastcell & ":AE" & lastrecordAGING).Select
End Sub


Mike
 
J

JW

hi,

i have the following:

Dim lastrecordAGING As Long
   Range("AE5000").End(xlUp).Offset(0, 0).Select
    lastrecordAGING = Selection.Row
Range("E2").End(xlToRight).Offset(0, 1).Select
Range(Selection, Selection.End(xlDown)).Select

i am trying to figure out how i can amend the lasdt line so that it only
selects up to the lastrecordAGING.

thanks in advance,
geebee

One way

Sub likeThis()
Dim lRow As Long
lRow = Cells(Rows.Count, "AE").End(xlUp).Row
Range("E2:" & Cells(lRow, Range("E2").End(xlToRight) _
.Offset(0, 1).Column).Address).Select
End Sub
 
G

geebee

hi,

this recommended code looks like it selects the last row like its supposed
to, but it selects too many columns. i just want it to select the most
recently added column. here is the code i have. the line which adds the new
column is maked with "*"

Range("E1").End(xlToRight).Offset(0, 0).Select
Selection.Copy
Range("E1").End(xlToRight).Offset(0, 1).Select "*"
Selection.Value = Format(CurrentReportMonth, "mmm-yy")
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _ "*"
SkipBlanks:=False, Transpose:=False

Dim lRow As Long
lRow = Cells(Rows.Count, "AE").End(xlUp).Row
Range("H2:" & Cells(lRow, Range("H2").End(xlToRight) _
..Offset(0, 1).Column).Address).Select


thanks in advance,
geebee
 
G

geebee

hi,

never mind, i figured it out.

thanks


geebee said:
hi,

this recommended code looks like it selects the last row like its supposed
to, but it selects too many columns. i just want it to select the most
recently added column. here is the code i have. the line which adds the new
column is maked with "*"

Range("E1").End(xlToRight).Offset(0, 0).Select
Selection.Copy
Range("E1").End(xlToRight).Offset(0, 1).Select "*"
Selection.Value = Format(CurrentReportMonth, "mmm-yy")
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _ "*"
SkipBlanks:=False, Transpose:=False

Dim lRow As Long
lRow = Cells(Rows.Count, "AE").End(xlUp).Row
Range("H2:" & Cells(lRow, Range("H2").End(xlToRight) _
.Offset(0, 1).Column).Address).Select


thanks in advance,
geebee
 

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

Top