Another dumb question

S

shimeel

Hello...
i dont know very much about excel or VB and this may seem very dumb ..
but this is what i need to do ...

i recorded a macro, and in it, i do this .

Range("I11").Select
Selection.End(xlDown).Select
Range("H259").Select

now, column I had entries down to 259, and i went to the cell to th
left of the last entry in 'I' to enter stuff in it.

but, 'I' wont always go down to 259. So, how can i enter stuff in th
cell left of the last entry in 'I' regardless of how many elements i
had
 
F

Frank Kabel

Hi
try the following macro:
sub foo()
dim lastrow as long
LastRow = .Cells(Rows.Count, "I").End(xlUp).Row
cells(lastrow,"H").value="your stuff"
end sub
 
D

Dave Peterson

typo alert.

Frank has a .cells(rows.count, "I")... line in there. That leading dot requires
a With statement:

so either:

sub foo()
dim lastrow as long
with activesheet
LastRow = .Cells(.Rows.Count, "I").End(xlUp).Row
.cells(lastrow,"H").value="your stuff"
end with
end sub

or

sub foo()
dim lastrow as long
LastRow = Cells(Rows.Count, "I").End(xlUp).Row
cells(lastrow,"H").value="your stuff"
end sub
 
F

Frank Kabel

Hi Dave
good spot. So maybe:
sub foo()
dim lastrow as long
with activesheet
LastRow = .Cells(Rows.Count, "I").End(xlUp).Row
.cells(lastrow,"H").value="your stuff"
end with
end sub
 
L

L. Howard Kittle

Hi Shimeel,

Here's one way.

Sub TheEnd()
Range("I1").End(xlDown).Offset(0, -1).Value = "XXX"
End Sub

HTH
Regards,
Howard
 
Top