View Single Post
  #4   Report Post  
David McRitchie
 
Posts: n/a
Default

worked for me in Excel 2000 after dimensioning LogWksh
but failure to dimension would get a very explicit error, as
would not having the named worksheet. Do you have
Option Explicit
at the top of the module. LastRow should be as Long.
Try copying the code again.

Dim LastRow As Long, LogWksh As Worksheet
Set LogWksh = Worksheets("TestSheet")
With LogWksh
LastRow = .Cells(.Rows.Count, "A").End(xlUp).row
'-- MsgBox LastRow
End With

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"daniel chen" wrote in message ...
The macro was working fine when I first wrote it.
Sometime it would stop working while I am on the net.
I did try - Dim LastRow as Long
as well as - Dim LastRow as Variant
It ceased to execute at - LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
with an error message "Type mismatch"

"Don Guillett" wrote in message
...
you did not tell us what "did not work sometime" means. What doesn't work?
what message?
try
dim last row as LONG

--
Don Guillett
SalesAid Software

"daniel chen" wrote in message
...
The following codes did not work sometime.
Can you help me with its limitation if any, Please.
It hang up as "Type mismatch"
on LastRow = Cells(.Rows.Count, "A").End(xlUp).Row

Dim LastRow As Integer
Set LogWksh = Worksheets("TestSheet")
With LogWksh
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With