LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Need refresher of some basic programming code

Errata:

Set R = WS.Cells.Find(what:="*", after:=WS.Cells(WS.Cells.Count))

should be

Set R = WS.Cells.Find(what:="*", after:=WS.Cells(WS.Cells.Count),
searchdirection:=xlPrevious)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Chip Pearson" wrote in message
...
Forgot to paste the code.

Sub LastCell()
Dim R As Range
Dim WS As Worksheet
Set WS = ActiveSheet
Set R = WS.Cells.Find(what:="*", after:=WS.Cells(WS.Cells.Count))
If R Is Nothing Then
Debug.Print "R Is Nothing (Blank WS)"
Else
Debug.Print "Last Cell: " & R.Address
End If
End Sub

Sub LastRowOfColumn()
Dim R As Range
Dim WS As Worksheet
Const COL_LETTER = "F"
Set WS = ActiveSheet
With WS
Set R = .Cells(.Rows.Count, COL_LETTER).End(xlUp)
End With
If (R.Row = 1) And (R.Value = vbNullString) Then
Debug.Print "Blank column"
Else
Debug.Print "Last Used Row In Column " & COL_LETTER & ": " & R.Row
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Chirs" wrote in message
...
1. What's the code to find the last row in a Column (Field) that has
data,
even if there are blank rows in-between?

2. Code to find last row on Sheet that has data, even if there are blank
rows
in-between on Sheet?

Thank you



 
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
basic VBA programming Simon Lloyd[_900_] Excel Programming 4 December 7th 06 02:37 AM
basic VBA programming Tom Ogilvy Excel Programming 1 December 5th 06 11:37 PM
basic VBA programming Corey Excel Programming 0 December 5th 06 05:10 AM
Basic programming help MaR Excel Programming 3 July 27th 06 09:44 AM
v.basic misc programming ? mark kubicki Excel Programming 6 February 5th 04 05:06 PM


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