Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Type mismatch on If rng.Value < "0" Then


I have this loop below that I programmed on my machine at home, but when
I take the same file I run it on at home and the same code and plug it
in on another machine at home or even my machine at work I get an error
that points to the 'If rng.Value < "0" Then line that says

Run-time error '13':
Type mismatch



Code:
--------------------
For i = LaRow To 2 Step -1
Set rng = Range("T" & i)
If rng.Value < "0" Then
Range("A" & i & ":AE" & i).Interior.ColorIndex = 38
Range("A" & i & ":AE" & i).Interior.Pattern = xlSolid
Range("AR" & i).Value = "1"
End If
Next
--------------------


Earlier in the code I have the values in Column T formatted into
currency, like so.


Code:
--------------------
Range("T" & i).Style = "Currency"
--------------------


Maybe that has something to do with it? Any help on this error is
appreciated. Thanks in advance.


--
DKY
------------------------------------------------------------------------
DKY's Profile: http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=393837

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Type mismatch on If rng.Value < "0" Then


Your code works for me (if LaRow is properly defined). Make sure
you have a value assigned to this variable like

LaRow =Cells.SpecialCells(xlCellTypeLastCell).Row


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=393837

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Type mismatch on If rng.Value < "0" Then


Here's what I got.
LaRow = Cells(Rows.Count, "E").End(xlUp).Row

and this code works perfectly fine on my machine that I made it on.
Problem is when I put it on another machine, it doesn't work. I don't
understand. If you want to see all my code then I'll show it to you,
but that's where it pointed me at in the debug. Why won't it work on
some machines? Same file, Same code....


--
DKY
------------------------------------------------------------------------
DKY's Profile: http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=393837

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Type mismatch on If rng.Value < "0" Then

If the machine where it is a problem is running xl97, then xl97 has problems
comparing a number to a string. Take the double quotes away from "0" and
just say

if rng.value < 0 then

--
Regards,
Tom Ogilvy


"DKY" wrote in message
...

Here's what I got.
LaRow = Cells(Rows.Count, "E").End(xlUp).Row

and this code works perfectly fine on my machine that I made it on.
Problem is when I put it on another machine, it doesn't work. I don't
understand. If you want to see all my code then I'll show it to you,
but that's where it pointed me at in the debug. Why won't it work on
some machines? Same file, Same code....


--
DKY
------------------------------------------------------------------------
DKY's Profile:

http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=393837



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Type mismatch on If rng.Value < "0" Then


I'm running xl 2003 on both machines and I tried removing quotes and
get the same error. I dont know what to do

--
DK
-----------------------------------------------------------------------
DKY's Profile: http://www.excelforum.com/member.php...fo&userid=1451
View this thread: http://www.excelforum.com/showthread.php?threadid=39383



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Type mismatch on If rng.Value < "0" Then

Dim i as Long, rng as Range
For i = LaRow To 2 Step -1
Set rng = Range("T" & i)
if not iserror(rng) and isnumeric(rng) then
If rng.Value < 0 Then
Range("A" & i & ":AE" & i).Interior.ColorIndex = 38
Range("A" & i & ":AE" & i).Interior.Pattern = xlSolid
Range("AR" & i).Value = 1
End If
End If
Next


--
Regards,
Tom Ogilvy


"DKY" wrote in message
...

I'm running xl 2003 on both machines and I tried removing quotes and I
get the same error. I dont know what to do.


--
DKY
------------------------------------------------------------------------
DKY's Profile:

http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=393837



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Type mismatch on If rng.Value < "0" Then


Okay, I found out so far that when the macro is in error, i is equal to
449. Meaning that this macro is having a problem with the value of
T449. T449 is #N/A (technically, T449 is a formula that says
=(H449*R449)+S449......and H449 equals 0, R449 equals 2.98 and S449 is
blank.) This macro is obviously having a problem with the #N/A value.


--
DKY
------------------------------------------------------------------------
DKY's Profile: http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=393837

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
"Type mismatch" when I try to fill an Array variable with "+" [email protected] Excel Discussion (Misc queries) 1 April 17th 07 01:28 PM
multiple file uploading - runtime error'13': type mismatch "While Counter <= UBound(FName)" Sinner Excel Discussion (Misc queries) 3 March 1st 07 09:44 AM
Run-time Error "13" - File Type Mismatch brentm Excel Programming 1 February 10th 05 05:09 PM
"FIND" generates "Type mismatch" error quartz[_2_] Excel Programming 5 November 16th 04 03:29 PM
Copying data to another worksheet gives "Type Mismatch" error TB[_3_] Excel Programming 6 July 28th 03 12:44 PM


All times are GMT +1. The time now is 11:18 AM.

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"