LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Code works 1st time then Type Mismatch when checking for not blank cells

I have some VBA code writing info to a spreadsheet. At one point, I loop
from row 200 backwards looking for a row with text so that I can indicate
that this is the last row.
After I have written a bunch of text, this runs and everything is fine. But
then I add some more text and I get a "Type Mismatch" error.


For n = 200 To 1 Step -1
If oxlWks.Worksheets("Sheet1").Range("B" & n) Or
oxlWks.Worksheets("Sheet1").Range("A" & n) < "" Then
ilastrow = n
Exit For
End If
Next n

As I say, it goes thru fine but the next time I run it, it crashes on the
line that checks for a not empty condition. The text is bold but that is
the only difference between the type of text that was there the first time
through. How in the world do I get a "Type Mismatch"? I have looked at a
watch window and it shows just what I see on the spreadsheet. I know a
crude work-around, but this is bugging me.

Thanks

p.s. if there is a lastrow function in Excel, fine. But I still want to
know why this does not work.


 
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
run-time error 13: Type mismatch? Marko Enula Excel Discussion (Misc queries) 2 February 5th 08 01:00 PM
run-time 13 Type mismatch simonsmith Excel Discussion (Misc queries) 2 May 18th 06 04:14 PM
[Q] Save As throws type mismatch error in control's code? Jason Weiss Excel Discussion (Misc queries) 1 July 16th 05 04:21 AM


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