PDA

View Full Version : Solved: how to define the cells?



maryam
04-26-2007, 08:13 AM
I am trying the following code under sheet_activate event but it gives error.
For i = 1 To 100
If Cells(12, i).Value <> "" And Cells(13, i).Value <> "" Then

Cells(14, i) = Cells(12, i).Value - 25 * Cells(13, i).Value
End If
Next

the error shows is application-defined or object-defined error. it seems the problem is with i at cells( , i) and we cannot have variable in paranteses. How to solve this problem and how to write other way?

lucas
04-26-2007, 08:31 AM
works fine for me....I did put your operation in parenthesis so the subtraction is done before the multiplication:
Cells(14, i) = (Cells(12, i).Value - 25) * Cells(13, i).Value

Bob Phillips
04-26-2007, 09:16 AM
Do you have text in any of the cells?