Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Last cell location


Lets say I have 100 rows and 5 columns (upto E column) of data in
spreadsheet. What will be the best way to get the location of last cel
in the spread-sheet (in this case E100) so that I can use row and colum
variables. I would like to use those when I want to write a formula i
one cell and copy that along the column or do a selection etc.

Thanks,
Ja

--
sa0200
-----------------------------------------------------------------------
sa02000's Profile: http://www.excelforum.com/member.php...fo&userid=2774
View this thread: http://www.excelforum.com/showthread.php?threadid=47256

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

set rng = cells(rows.count,"E").End(xlup)

--
Regads,
Tom Ogilvy

"sa02000" wrote in
message ...

Lets say I have 100 rows and 5 columns (upto E column) of data in a
spreadsheet. What will be the best way to get the location of last cell
in the spread-sheet (in this case E100) so that I can use row and column
variables. I would like to use those when I want to write a formula in
one cell and copy that along the column or do a selection etc.

Thanks,
Jay


--
sa02000
------------------------------------------------------------------------
sa02000's Profile:

http://www.excelforum.com/member.php...o&userid=27747
View this thread: http://www.excelforum.com/showthread...hreadid=472569



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


is there a way to not hardcode column...
Also, can i use these row and column variables in a vlookup formula?

Ja

--
sa0200
-----------------------------------------------------------------------
sa02000's Profile: http://www.excelforum.com/member.php...fo&userid=2774
View this thread: http://www.excelforum.com/showthread.php?threadid=47256

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Last cell location

-- yes, you can use the results returned. Here are some other ways:

If you want to find the "RealLastCell with data:"


In a thread subject Change What Excel Believes Is The Last Cell
In Microsoft.Public.Excel.Programming on October 15, 1999


This was posted by John Green
"The following code will find the last row and last column that contain data
on the active worksheet:"


Sub GetRealLastCell()
Dim RealLastRow As Long
Dim RealLastColumn As Long
Range("A1").Select
On Error Resume Next
RealLastRow = _
Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
RealLastColumn = _
Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Column
Cells(RealLastRow, RealLastColumn).Select
End Sub


[ the cell selected is at the intersection of the last row and last column
and may be empty, so you can use each result independently]


This is a version posted by David Chazin with some additional error checking


Sub LastCell_Select()
'David Chazin 05-Mar-1999
'Selects the cell at the bottom-right corner of the used area
' of the currently selected worksheet.
Range(LastCell_Get()).Select
End Sub


Function LastCell_Get() As String


'David Chazin -- September 1999.
'Returns the Address (e.g. "$AW$235") of the cell at the
' bottom-right corner of the used area of the currently
' selected worksheet. Returns "" if the worksheet is empty.
' Thanks to Dave Braden for the idea of trapping for an
' empty worksheet. (This is not the way he would implement
' it, but the idea itself is his).


On Error GoTo LastCell_Get_ErrorHandler


If Range("A1").SpecialCells(xlLastCell).Value < "" Then
LastCell_Get = Range("A1").SpecialCells(xlLastCell).Address()
Else
LastCell_Get = _
Cells(Cells.Find("*", ActiveCell.SpecialCells(xlLastCell), , , _
xlByRows, xlPrevious).Row, _
Cells.Find("*", ActiveCell.SpecialCells(xlLastCell), , , _
xlByColumns, xlPrevious).Column).Address()
End If
Exit Function
LastCell_Get_ErrorHandler:


If Err.Number = 91 Then
'If the worksheet is empty....
LastCell_Get = ""
Else
Call MsgBox("Error #" & Err.Number & " was generated by " & _
Err.Source & ": " & Err.Description, vbOKOnly + vbExclamation, _
"LastCell_Get()", Err.HelpFile, Err.HelpContext)
End If


End Function


Regards,
Tom Ogilvy

"sa02000" wrote in
message ...

is there a way to not hardcode column...
Also, can i use these row and column variables in a vlookup formula?

Jay


--
sa02000
------------------------------------------------------------------------
sa02000's Profile:

http://www.excelforum.com/member.php...o&userid=27747
View this thread: http://www.excelforum.com/showthread...hreadid=472569



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


How do I use a variable in a name of a sheet or a file or something.
For example, every month I create a new file and do similar step
except the name of month on sheets and file names. So, if I have shee
named Aug_download last month, this month I want to name this sheet a
Sep_download. So, I was thinking I can create a user input of mont
name and then concatenate that to the name of sheet. But how do I ge
around actually doing it?

Ja

--
sa0200
-----------------------------------------------------------------------
sa02000's Profile: http://www.excelforum.com/member.php...fo&userid=2774
View this thread: http://www.excelforum.com/showthread.php?threadid=47256

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
CELL LOCATION CONGOGRY Excel Worksheet Functions 2 August 5th 09 03:28 PM
Macro - save to current location vs excel default location leezard Excel Discussion (Misc queries) 0 October 28th 08 03:04 PM
Max #, Cell, Row location nastech Excel Discussion (Misc queries) 3 June 12th 06 10:14 AM
automatic offset cell location when there is a value in a selected cell. kuansheng Excel Worksheet Functions 0 February 23rd 06 01:40 AM
Cell Location Richard Excel Discussion (Misc queries) 2 August 31st 05 08:39 PM


All times are GMT +1. The time now is 12:03 AM.

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"