Thread: last record
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
geebee geebee is offline
external usenet poster
 
Posts: 190
Default last record

hi,

never mind, i figured it out.

thanks


"geebee" wrote:

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


"JW" wrote:

On May 22, 12:33 pm, geebee (noSPAMs) wrote:
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