Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
rroach
 
Posts: n/a
Default type mismatch--how to fix


The following statement runs in a macro. Runs OK if there is any data in
column V, crashes with Type Mismatch error if column V is blank. How do
I deal with that?

TIA,

Rob

Range("z5").Formula = "=ROW(OFFSET(v1,COUNTA(V:V)-1,0))"


--
rroach
------------------------------------------------------------------------
rroach's Profile: http://www.excelforum.com/member.php...o&userid=21093
View this thread: http://www.excelforum.com/showthread...hreadid=387127

  #2   Report Post  
bj
 
Posts: n/a
Default

try
Range("z5").Formula =
"=if(iserror(ROW(OFFSET(v1,COUNTA(V:V)-1,0)),~"~",ROW(OFFSET(v1,COUNTA(V:V)-1,0)"
I think you need the tildes in front of the " if it doesn't work reference a
cell with nothing in it. in this case it cound be
Range("z5").Formula =
"=if(iserror(ROW(OFFSET(v1,COUNTA(V:V)-1,0)),V1,ROW(OFFSET(v1,COUNTA(V:V)-1,0)"
"rroach" wrote:


The following statement runs in a macro. Runs OK if there is any data in
column V, crashes with Type Mismatch error if column V is blank. How do
I deal with that?

TIA,

Rob

Range("z5").Formula = "=ROW(OFFSET(v1,COUNTA(V:V)-1,0))"


--
rroach
------------------------------------------------------------------------
rroach's Profile: http://www.excelforum.com/member.php...o&userid=21093
View this thread: http://www.excelforum.com/showthread...hreadid=387127


  #3   Report Post  
Alan Beban
 
Posts: n/a
Default

The problem is that with Column V empty, the formula converts to

=IF(ROW(OFFSET(v1,-1,0))) and you can't offset -1 row from Row 1, the
row of Cell V1.

Consider:

Range("z5").Formula = _
"=IF(ISERROR(ROW(OFFSET(V1,COUNTA(V:V)-1,0))),""error"", _
ROW(OFFSET(V1,COUNTA(V:V)-1,0)))"

Alan Beban

rroach wrote:
The following statement runs in a macro. Runs OK if there is any data in
column V, crashes with Type Mismatch error if column V is blank. How do
I deal with that?

TIA,

Rob

Range("z5").Formula = "=ROW(OFFSET(v1,COUNTA(V:V)-1,0))"


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
Database Query -- Data Type Mismatch StephenP Excel Discussion (Misc queries) 0 April 14th 05 07:05 PM
Type mismatch on LastRow daniel chen Excel Discussion (Misc queries) 8 April 11th 05 02:29 AM
Why type mismatch - R/T error 13 Jim May Excel Discussion (Misc queries) 5 January 9th 05 06:45 PM
Convert data type of cells to Text,Number,Date and Time Kevin Excel Worksheet Functions 1 December 31st 04 12:57 PM
Convert data of cells to any type: Number, Date&Time, Text Kevin Excel Discussion (Misc queries) 0 December 30th 04 06:55 AM


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