ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   'Type mismatch' error! (https://www.excelbanter.com/excel-programming/376039-type-mismatch-error.html)

[email protected]

'Type mismatch' error!
 

A cell has the value=0.023. The Category is chosen as 'General' for
this cell.

I want to get the inverse of that cell value i.e. 0.023, and ignore the
decimal point in the result.

1/0.023 = 43.478 = 43

Here is the excerpt from the macro:
Line1 oneRequestTime = 1 / Worksheets("Banking").Cells("B4").Value
Line2 Application.WorksheetFunction.Floor(oneRequestTime , 1)

But, the 'Type mismatch' error is reported at the Line1. How do I get
rid of this error. I tried to declare 'oneRequestTime' with different
types. But, it did not help!


Andrew Taylor

'Type mismatch' error!
 
Cells() takes Row and column as params, not a cell ref
- you need:
Range("B4")
or
Cells (4,2)
instead of
Cells("B4")

wrote:
A cell has the value=0.023. The Category is chosen as 'General' for
this cell.

I want to get the inverse of that cell value i.e. 0.023, and ignore the
decimal point in the result.

1/0.023 = 43.478 = 43

Here is the excerpt from the macro:
Line1 oneRequestTime = 1 / Worksheets("Banking").Cells("B4").Value
Line2 Application.WorksheetFunction.Floor(oneRequestTime , 1)

But, the 'Type mismatch' error is reported at the Line1. How do I get
rid of this error. I tried to declare 'oneRequestTime' with different
types. But, it did not help!



JLGWhiz

'Type mismatch' error!
 
I prefer to assign variables to long references like:
MyValue = Worksheets("Banking").Range("$B$4").Value
and then apply it like:
oneRequestTime = 1 / MyValue

Does the same thing, but if you use it more than once it is a lot neater.

" wrote:


A cell has the value=0.023. The Category is chosen as 'General' for
this cell.

I want to get the inverse of that cell value i.e. 0.023, and ignore the
decimal point in the result.

1/0.023 = 43.478 = 43

Here is the excerpt from the macro:
Line1 oneRequestTime = 1 / Worksheets("Banking").Cells("B4").Value
Line2 Application.WorksheetFunction.Floor(oneRequestTime , 1)

But, the 'Type mismatch' error is reported at the Line1. How do I get
rid of this error. I tried to declare 'oneRequestTime' with different
types. But, it did not help!




All times are GMT +1. The time now is 07:01 AM.

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