Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default getting size or setting it?

Hi!

How do I get the "last" used (max x and y) cell of my sheet?

how do I set it?

BR
Sonnich

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,886
Default getting size or setting it?

Hi

One way

Sub Lastcellused()
Dim lRow as Long, lCol as Long
ActiveSheet.UsedRange
With Cells.SpecialCells(xlCellTypeLastCell)
lRow = .row
lCol = .Column
End With
End Sub
--
Regards

Roger Govier


"Sonnich" wrote in message
ups.com...
Hi!

How do I get the "last" used (max x and y) cell of my sheet?

how do I set it?

BR
Sonnich



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default getting size or setting it?

Hi Sonnich,

Try:

'=============
Public Sub LastRowNCol()
Dim SH As Worksheet

Set SH = ActiveWorkbook.Sheets("Sheet1") '<<==== CHANGE

MsgBox "Last populated row = Row # " & LastRow(SH) _
& vbNewLine _
& "Last populated row = Column # " & LastCol(SH)

End Sub

'--------------------

Function LastRow(SH As Worksheet)
On Error Resume Next
LastRow = SH.Cells.Find(What:="*", _
After:=SH.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function

'--------------------

Function LastCol(SH As Worksheet)
On Error Resume Next
LastCol = SH.Cells.Find(What:="*", _
After:=SH.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
On Error GoTo 0
End Function
'<<=============

For information on resetting the UsedRange, see Debra Dalgleish at:

http://www.contextures.com/xlfaqApp.html#Unused


---
Regards,
Norman


"Sonnich" wrote in message
ups.com...
Hi!

How do I get the "last" used (max x and y) cell of my sheet?

how do I set it?

BR
Sonnich



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
Setting the zoom size of a new window from 100% to 75% MongoMan Excel Discussion (Misc queries) 0 June 18th 08 11:30 PM
Setting Listbox Size VBA Sandy Excel Worksheet Functions 1 April 27th 07 05:48 PM
Problem with setting chart size in VB.NET XxLicherxX Excel Programming 0 January 26th 06 03:52 PM
Setting size of icons Rob Excel Programming 0 January 26th 05 08:33 PM
setting a chart size julio Excel Programming 1 December 18th 03 05:26 PM


All times are GMT +1. The time now is 10:15 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"