Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
TK TK is offline
external usenet poster
 
Posts: 177
Default Find the last Row in a Range

Trying to write to the last row in a range. The following code works down to
( The next line fails ....
Thanks:


Private Function FindLastRow()
Dim R As Long
R = 2
Do While R < 65536 And Len(Cells(R, 11).Text) 0
R = R + 1
Loop
FindLastRow = R
End Function

Private Sub ListBox1_Click()
Lastrow = FindLastRow - 1
MsgBox Lastrow
Sheet1.Range("k1").Value = UserForm1.ListBox1.Value

( The next line fails - how should it be written?)
Sheet1.Range("kLastrow").Value = UserForm1.ListBox1.Value

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find the last Row in a Range

Sheet1.Range("k" & Lastrow).Value = UserForm1.ListBox1.Value


you can also get the lastrow with

lastrow = cells(rows.count,11).End(xlup).row
--
Regards,
Tom Ogilvy



"TK" wrote in message
...
Trying to write to the last row in a range. The following code works down

to
( The next line fails ....
Thanks:


Private Function FindLastRow()
Dim R As Long
R = 2
Do While R < 65536 And Len(Cells(R, 11).Text) 0
R = R + 1
Loop
FindLastRow = R
End Function

Private Sub ListBox1_Click()
Lastrow = FindLastRow - 1
MsgBox Lastrow
Sheet1.Range("k1").Value = UserForm1.ListBox1.Value

( The next line fails - how should it be written?)
Sheet1.Range("kLastrow").Value = UserForm1.ListBox1.Value

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
TK TK is offline
external usenet poster
 
Posts: 177
Default Find the last Row in a Range



Thanks Tom
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
Find Last cell in Range when range is date format default105 Excel Discussion (Misc queries) 5 July 7th 09 03:11 PM
Find the MAX number in range, then find... pgarcia Excel Discussion (Misc queries) 4 September 19th 08 06:58 PM
Find a range of values in a range of cells Jack Taylor Excel Worksheet Functions 20 November 25th 06 01:26 PM
Find dates in a range; then sum values in that range by a criteria Anders Excel Discussion (Misc queries) 4 October 21st 05 03:41 PM
Range.Find returns cell outside of range when range set to single cell Frank Jones Excel Programming 12 June 10th 04 04:22 AM


All times are GMT +1. The time now is 05:49 PM.

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"