Thread: Last cell
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Last cell

Hi Hawk,

It is not clear (to me) what you are trying to do.

The suggested code returns the last populated cell in column J, in
accordance with your request:

Trying to make a macro that will find the last cell, that can vary,
in colum J


If your intention is to select that cell, then try:

Dim rng As Range

Set rng = Cells(Rows.Count, "J").End(xlUp)

rng.select

However, it is rarely necessary, and usually inefficient, to make such
selections. Instead, try something like:

'=============
Public Sub Tester()
Dim rng As Range

'Define last populated cell in column J
Set rng = Cells(Rows.Count, "J").End(xlUp)

'Do something with the range object, e.g.:
rng.Interior.ColorIndex = 6
End Sub
'<<=============


---
Regards,
Norman


"hawk" wrote in message
news:JSfzf.373982$ki.20044@pd7tw2no...
Norman, tried the following but no work...
---------------------------------------------------------------------------------
Sub Macro1()
'
'
Application.Goto Reference:="R5C8"
Dim rng As Range

Set rng = Cells(Rows.Count, "J").End(xlUp)

'Selection.End(xlDown).Select
'Range("A1:J68").Select
Range("J68").Activate

End Sub

---------------------------------------------------------------------------------