ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Type mismatch (https://www.excelbanter.com/excel-programming/318994-type-mismatch.html)

Teresa

Type mismatch
 
This is an extract from my macro:

For m = 2 To 20
.Cells(k + 2, m).Value = .Cells(k, m) - .Cells(k + 1, m)

I get a type mismatch, I think that a lot of cells in the worksheet I'm
evaluating
are words.
How do I rectify this? Help is greatly appreciated



Bob Phillips[_6_]

Type mismatch
 
Maybe something like

For m = 2 To 20
.Cells(k + 2,m).Value = IIf(IsNumeric(.Cells(k, m) Value), Cells(k,
m) .Value, 0) - _
IIf(IsNumeric(.Cells(k + 1,
m).Value), .Cells(k + 1, m).Value, 0)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"teresa" wrote in message
...
This is an extract from my macro:

For m = 2 To 20
.Cells(k + 2, m).Value = .Cells(k, m) - .Cells(k + 1, m)

I get a type mismatch, I think that a lot of cells in the worksheet I'm
evaluating
are words.
How do I rectify this? Help is greatly appreciated






All times are GMT +1. The time now is 10:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com