Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 'LastRow' Function not working


This is basically what I have. It was working at one time. Not sure why now.


__________________________________________________ __

Private Sub btnProcess_Click()
btnProcess.Enabled = False

Call test1

End Sub
__________________________________________________ __
Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
after:=sh.Range("B0"), _
lookat:=xlPart, _
LookIn:=xlValues, _
searchorder:=xlByRows, _
searchdirection:=xlPrevious, _
MatchCase:=False).Row

On Error GoTo 0
End Function
__________________________________________________ _

Public Sub ProcessSingle1(ws As Worksheet, WS2 As Worksheet, Str As String)

Dim LRow As Long
LRow = LastRow(WS2)
End Sub
__________________________________________________ _

Sub test1()
ActiveCell.Activate
Dim ws As Worksheet
Dim WS2 As Worksheet
Dim Str As String



'UNSCHEDULED
Set ws = Sheets("Unsc.")
Set WS2 = Sheets("Print281")
Str = "81"
Call ProcessSingle(ws, WS2, Str)

End Sub
__________________________________________________ _


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default 'LastRow' Function not working

Hi,
To look for the last row of data in a column, say column B of sheet Wsh
LastRow = Wsh.Range("B65536").End(xlup).Row
It assumes data stop before row 65536.
It is the same as manually selecting B65536 and doing a CTRL+ArrowKeyUP
--
Regards,
Sébastien


"Randy Reese" wrote:


This is basically what I have. It was working at one time. Not sure why now.


__________________________________________________ __

Private Sub btnProcess_Click()
btnProcess.Enabled = False

Call test1

End Sub
__________________________________________________ __
Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
after:=sh.Range("B0"), _
lookat:=xlPart, _
LookIn:=xlValues, _
searchorder:=xlByRows, _
searchdirection:=xlPrevious, _
MatchCase:=False).Row

On Error GoTo 0
End Function
__________________________________________________ _

Public Sub ProcessSingle1(ws As Worksheet, WS2 As Worksheet, Str As String)

Dim LRow As Long
LRow = LastRow(WS2)
End Sub
__________________________________________________ _

Sub test1()
ActiveCell.Activate
Dim ws As Worksheet
Dim WS2 As Worksheet
Dim Str As String



'UNSCHEDULED
Set ws = Sheets("Unsc.")
Set WS2 = Sheets("Print281")
Str = "81"
Call ProcessSingle(ws, WS2, Str)

End Sub
__________________________________________________ _



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default 'LastRow' Function not working

Range("B0") is not a valid cell reference.
It will have to be a named range if it's going to work.


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Randy Reese" wrote in message
et...

This is basically what I have. It was working at one time. Not sure why

now.


__________________________________________________ __

Private Sub btnProcess_Click()
btnProcess.Enabled = False

Call test1

End Sub
__________________________________________________ __
Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
after:=sh.Range("B0"), _
lookat:=xlPart, _
LookIn:=xlValues, _
searchorder:=xlByRows, _
searchdirection:=xlPrevious, _
MatchCase:=False).Row

On Error GoTo 0
End Function
__________________________________________________ _

Public Sub ProcessSingle1(ws As Worksheet, WS2 As Worksheet, Str As

String)

Dim LRow As Long
LRow = LastRow(WS2)
End Sub
__________________________________________________ _

Sub test1()
ActiveCell.Activate
Dim ws As Worksheet
Dim WS2 As Worksheet
Dim Str As String



'UNSCHEDULED
Set ws = Sheets("Unsc.")
Set WS2 = Sheets("Print281")
Str = "81"
Call ProcessSingle(ws, WS2, Str)

End Sub
__________________________________________________ _




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default 'LastRow' Function not working

This method for finding the last row containing data should start its search
in the A1 cell.

What does B0 represent. Is it a name? If so, it should refer to A1.

Try replacing B0 with A1.

John Green



"Randy Reese" wrote in message
et...

This is basically what I have. It was working at one time. Not sure why

now.


__________________________________________________ __

Private Sub btnProcess_Click()
btnProcess.Enabled = False

Call test1

End Sub
__________________________________________________ __
Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
after:=sh.Range("B0"), _
lookat:=xlPart, _
LookIn:=xlValues, _
searchorder:=xlByRows, _
searchdirection:=xlPrevious, _
MatchCase:=False).Row

On Error GoTo 0
End Function
__________________________________________________ _

Public Sub ProcessSingle1(ws As Worksheet, WS2 As Worksheet, Str As

String)

Dim LRow As Long
LRow = LastRow(WS2)
End Sub
__________________________________________________ _

Sub test1()
ActiveCell.Activate
Dim ws As Worksheet
Dim WS2 As Worksheet
Dim Str As String



'UNSCHEDULED
Set ws = Sheets("Unsc.")
Set WS2 = Sheets("Print281")
Str = "81"
Call ProcessSingle(ws, WS2, Str)

End Sub
__________________________________________________ _




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 'LastRow' Function not working

Change
after:=sh.Range("B0"),

to
after:=sh.Range("IV65536"),

--
Regards
Tom Ogilvy


"Randy Reese" wrote in message
et...

This is basically what I have. It was working at one time. Not sure why

now.


__________________________________________________ __

Private Sub btnProcess_Click()
btnProcess.Enabled = False

Call test1

End Sub
__________________________________________________ __
Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
after:=sh.Range("B0"), _
lookat:=xlPart, _
LookIn:=xlValues, _
searchorder:=xlByRows, _
searchdirection:=xlPrevious, _
MatchCase:=False).Row

On Error GoTo 0
End Function
__________________________________________________ _

Public Sub ProcessSingle1(ws As Worksheet, WS2 As Worksheet, Str As

String)

Dim LRow As Long
LRow = LastRow(WS2)
End Sub
__________________________________________________ _

Sub test1()
ActiveCell.Activate
Dim ws As Worksheet
Dim WS2 As Worksheet
Dim Str As String



'UNSCHEDULED
Set ws = Sheets("Unsc.")
Set WS2 = Sheets("Print281")
Str = "81"
Call ProcessSingle(ws, WS2, Str)

End Sub
__________________________________________________ _




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
Lastrow Bishop Excel Worksheet Functions 2 May 13th 09 05:22 PM
Lastrow - function not defined seed Excel Discussion (Misc queries) 2 August 7th 08 06:34 PM
Lastrow Mr. Damon[_2_] Excel Worksheet Functions 3 July 30th 08 04:12 PM
Go to lastrow using other column's lastrow stakar[_14_] Excel Programming 5 April 16th 04 03:42 PM
Help with LastRow JStone0218 Excel Programming 4 December 4th 03 04:50 PM


All times are GMT +1. The time now is 10:42 AM.

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"