#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Last cell

Trying to make a macro that will find the last cell, that can vary, in
colum J
but having trouble getting my brain around how to do it.
Any help appreciated.

Roger


Sub Macro1()
'
'
Application.Goto Reference:="R5C8"
'Selection.End(xlDown).Select
Range("A1:J68").Select
Range("J68").Activate
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Last cell

Hi Hawk,

Try:

Dim rng As Range

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


---
Regards,
Norman



"hawk" wrote in message
news:Arfzf.256935$2k.125854@pd7tw1no...
Trying to make a macro that will find the last cell, that can vary, in
colum J
but having trouble getting my brain around how to do it.
Any help appreciated.

Roger


Sub Macro1()
'
'
Application.Goto Reference:="R5C8"
'Selection.End(xlDown).Select
Range("A1:J68").Select
Range("J68").Activate
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Last cell

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

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

"Norman Jones" wrote in message
...
Hi Hawk,

Try:

Dim rng As Range

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


---
Regards,
Norman



"hawk" wrote in message
news:Arfzf.256935$2k.125854@pd7tw1no...
Trying to make a macro that will find the last cell, that can vary, in
colum J
but having trouble getting my brain around how to do it.
Any help appreciated.

Roger


Sub Macro1()
'
'
Application.Goto Reference:="R5C8"
'Selection.End(xlDown).Select
Range("A1:J68").Select
Range("J68").Activate
End Sub





  #4   Report Post  
Posted to microsoft.public.excel.programming
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

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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Last cell

Norm appreciate your input, but not quite what I'm looking for.
See comments at end of lines

Roger

Sub Macro1()
'
'
Application.Goto Reference:="R5C8"
Dim rng As Range

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

'Selection.End(xlDown).Select <=== thsi selects the last
cell with values in Col J 'Range("A1:J68").Select
<=== This selects range A1:j68
Range("J68").Activate **** what I need is to
be able to have the selection vary each time it is run.


depending on the amount of data in J the last cell can be different, Hope
I make myself clear.

End Sub




"Norman Jones" wrote in message
...
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

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







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Last cell

Hi Roger,

Perhaps I am being overly obtuse, but your intent is still not apparent to
me but, as a myopic stab, try:

Dim rng As Range

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

Range(Range("A1"), rng).Select


---
Regards,
Norman



"hawk" wrote in message
news:basAf.299205$2k.129089@pd7tw1no...
Norm appreciate your input, but not quite what I'm looking for.
See comments at end of lines

Roger

Sub Macro1()
'
'
Application.Goto Reference:="R5C8"
Dim rng As Range

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

'Selection.End(xlDown).Select <=== thsi selects the
last cell with values in Col J 'Range("A1:J68").Select <=== This selects
range A1:j68
Range("J68").Activate **** what I need is
to be able to have the selection vary each time it is run.


depending on the amount of data in J the last cell can be different, Hope
I make myself clear.

End Sub



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Last cell

Perfect just what I wanted, you did grrrreat,
tks

Roger'

"Norman Jones" wrote in message
...
Hi Roger,

Perhaps I am being overly obtuse, but your intent is still not apparent to
me but, as a myopic stab, try:

Dim rng As Range

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

Range(Range("A1"), rng).Select


---
Regards,
Norman



"hawk" wrote in message
news:basAf.299205$2k.129089@pd7tw1no...
Norm appreciate your input, but not quite what I'm looking for.
See comments at end of lines

Roger

Sub Macro1()
'
'
Application.Goto Reference:="R5C8"
Dim rng As Range

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

'Selection.End(xlDown).Select <=== thsi selects the
last cell with values in Col J 'Range("A1:J68").Select <=== This
selects range A1:j68
Range("J68").Activate **** what I need is
to be able to have the selection vary each time it is run.


depending on the amount of data in J the last cell can be different, Hope
I make myself clear.

End Sub





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Last cell

Okay, now take this one step further. How do you dynamicly get both the last
column and row for a spreadsheet that can change in size for both values?

I'm using this functionality to create a dynamic Pivot Table for varying
spreadsheets.

Thanks!

"Norman Jones" wrote:

Hi Hawk,

Try:

Dim rng As Range

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


---
Regards,
Norman



"hawk" wrote in message
news:Arfzf.256935$2k.125854@pd7tw1no...
Trying to make a macro that will find the last cell, that can vary, in
colum J
but having trouble getting my brain around how to do it.
Any help appreciated.

Roger


Sub Macro1()
'
'
Application.Goto Reference:="R5C8"
'Selection.End(xlDown).Select
Range("A1:J68").Select
Range("J68").Activate
End Sub




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Options Yuvraj Excel Discussion (Misc queries) 0 June 29th 09 11:20 AM
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Yuvraj Excel Discussion (Misc queries) 0 June 26th 09 06:01 PM
Populate a cell if values in cell 1 and cell 2 match cell 3 and 4 [email protected] Excel Worksheet Functions 1 August 22nd 08 02:04 AM
How to create/run "cell A equals Cell B put Cell C info in Cell D abmb161 Excel Discussion (Misc queries) 5 January 26th 06 06:36 PM
data validation to restrict input in cell based on value of cell above that cell NC Excel Programming 2 January 25th 05 07:11 AM


All times are GMT +1. The time now is 10:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"