Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default How do I determine the last cell in a Column

I know how to get the last cell in a column:

range("A65536").End(xlUp).address for the row number
range("A65536").End(xlUp).row for the row number

but I am not sure how to translate this to doing the same for the row.
Any help with be appreciated. Thanks.


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default How do I determine the last cell in a Column

Try...
Range("IV1").End(xlToLeft).Column

I prefer to use...

With ActiveSheet
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
lastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With

"Ayo" wrote:

I know how to get the last cell in a column:

range("A65536").End(xlUp).address for the row number
range("A65536").End(xlUp).row for the row number

but I am not sure how to translate this to doing the same for the row.
Any help with be appreciated. Thanks.


  #3   Report Post  
Posted to microsoft.public.excel.misc
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default How do I determine the last cell in a Column

Thanks Sheeloo. One more question, how do I use it in a for statement that
is looping through cells D14: T14 i.e.,

For Each c In Wsht.Range((4, 14), (4, lastColumn)).Cells
If c.Value = Range("B4") Then
getMSaddress = c.Address(ColumnAbsolute:=False)
Exit Function
End If
Next c


"Sheeloo" wrote:

Try...
Range("IV1").End(xlToLeft).Column

I prefer to use...

With ActiveSheet
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
lastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With

"Ayo" wrote:

I know how to get the last cell in a column:

range("A65536").End(xlUp).address for the row number
range("A65536").End(xlUp).row for the row number

but I am not sure how to translate this to doing the same for the row.
Any help with be appreciated. Thanks.


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How do I determine the last cell in a Column

dim c as range
Dim myRng as range
with wsht
set myrng = .range(.cells(4,14), .cells(4,lastcol))
end with

for each c in myrng.cells
.....

Ayo wrote:

Thanks Sheeloo. One more question, how do I use it in a for statement that
is looping through cells D14: T14 i.e.,

For Each c In Wsht.Range((4, 14), (4, lastColumn)).Cells
If c.Value = Range("B4") Then
getMSaddress = c.Address(ColumnAbsolute:=False)
Exit Function
End If
Next c

"Sheeloo" wrote:

Try...
Range("IV1").End(xlToLeft).Column

I prefer to use...

With ActiveSheet
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
lastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With

"Ayo" wrote:

I know how to get the last cell in a column:

range("A65536").End(xlUp).address for the row number
range("A65536").End(xlUp).row for the row number

but I am not sure how to translate this to doing the same for the row.
Any help with be appreciated. Thanks.



--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default How do I determine the last cell in a Column

Thanks Dave.

"Dave Peterson" wrote:

dim c as range
Dim myRng as range
with wsht
set myrng = .range(.cells(4,14), .cells(4,lastcol))
end with

for each c in myrng.cells
.....

Ayo wrote:

Thanks Sheeloo. One more question, how do I use it in a for statement that
is looping through cells D14: T14 i.e.,

For Each c In Wsht.Range((4, 14), (4, lastColumn)).Cells
If c.Value = Range("B4") Then
getMSaddress = c.Address(ColumnAbsolute:=False)
Exit Function
End If
Next c

"Sheeloo" wrote:

Try...
Range("IV1").End(xlToLeft).Column

I prefer to use...

With ActiveSheet
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
lastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With

"Ayo" wrote:

I know how to get the last cell in a column:

range("A65536").End(xlUp).address for the row number
range("A65536").End(xlUp).row for the row number

but I am not sure how to translate this to doing the same for the row.
Any help with be appreciated. Thanks.



--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default How do I determine the last cell in a Column

Try
Wsht.Range(Cells(14, 4), Cells(14, lastColumn)).Select
For Each c In Selection
If c.Value = Range("B4") Then
getMSaddress = c.Address
Exit For
End If
Next c

"Ayo" wrote:

Thanks Sheeloo. One more question, how do I use it in a for statement that
is looping through cells D14: T14 i.e.,

For Each c In Wsht.Range((4, 14), (4, lastColumn)).Cells
If c.Value = Range("B4") Then
getMSaddress = c.Address(ColumnAbsolute:=False)
Exit Function
End If
Next c


"Sheeloo" wrote:

Try...
Range("IV1").End(xlToLeft).Column

I prefer to use...

With ActiveSheet
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
lastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With

"Ayo" wrote:

I know how to get the last cell in a column:

range("A65536").End(xlUp).address for the row number
range("A65536").End(xlUp).row for the row number

but I am not sure how to translate this to doing the same for the row.
Any help with be appreciated. Thanks.


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How do I determine the last cell in a Column

This could cause trouble.

If you're going to qualify .range, it's a good idea to qualify cells:

Wsht.Range(wsht.Cells(14, 4), wsht.Cells(14, lastColumn)).Select

And if wsht isn't the activesheet, then the .Select will fail. I wouldn't
select the range to work on it.

Sheeloo wrote:

Try
Wsht.Range(Cells(14, 4), Cells(14, lastColumn)).Select
For Each c In Selection
If c.Value = Range("B4") Then
getMSaddress = c.Address
Exit For
End If
Next c

"Ayo" wrote:

Thanks Sheeloo. One more question, how do I use it in a for statement that
is looping through cells D14: T14 i.e.,

For Each c In Wsht.Range((4, 14), (4, lastColumn)).Cells
If c.Value = Range("B4") Then
getMSaddress = c.Address(ColumnAbsolute:=False)
Exit Function
End If
Next c


"Sheeloo" wrote:

Try...
Range("IV1").End(xlToLeft).Column

I prefer to use...

With ActiveSheet
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
lastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With

"Ayo" wrote:

I know how to get the last cell in a column:

range("A65536").End(xlUp).address for the row number
range("A65536").End(xlUp).row for the row number

but I am not sure how to translate this to doing the same for the row.
Any help with be appreciated. Thanks.



--

Dave Peterson
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
Determine if column contains duplicate value ABM Excel Discussion (Misc queries) 1 July 24th 08 08:00 PM
How to determine the column letter from Cell address Jean Excel Worksheet Functions 6 July 24th 06 03:04 AM
How can I determine the largest physical size cell in a column csa001 Excel Worksheet Functions 2 June 22nd 06 02:33 PM
Determine which column to use by date Mike Griffin Excel Worksheet Functions 5 March 2nd 06 01:18 PM
Determine if Value in column A exists in Column B TJKarakowski Excel Discussion (Misc queries) 3 July 19th 05 06:27 PM


All times are GMT +1. The time now is 12:38 PM.

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

About Us

"It's about Microsoft Excel"