Shed some light on this WS_Calculate macro.

  • Thread starter Thread starter L. Howard
  • Start date Start date
L

L. Howard

The * in the If statement is confusing me, is it the same as And, OR, or Either as it relates to the rngC.Value

What exact does the If statement say?

In my test to try to understand the statement I kept getting Type mismatch errors. Using A1 and B1 then pulling down to produce a small data set to apply the code to, and using = or <> "xx" instead of 99. Using numbers only seems to prevent that.

The col 46 = col 49 I understand.

Thanks.
Howard

Private Sub Worksheet_Calculate()
Dim LRow As Long
Dim rngC As Range

LRow = Cells(Rows.Count, 61).End(xlUp).Row
For Each rngC In Range("BI1:BI" & LRow)
If rngC.Value * rngC.Offset(, 1).Value = 99 Then
Cells(rngC.Row, 46) = Cells(rngC.Row, 49)
End If
Next
End Sub
 
Hi Howard,

Am Sat, 18 Jan 2014 22:06:35 -0800 (PST) schrieb L. Howard:
If rngC.Value * rngC.Offset(, 1).Value = 99 Then

both cells rngC and rngC.Offset(,1) should be NOT zero to change the
cell value in column 46.
IF you multiply to values and one of them is 0 the result = 0
So it is the same as writing
IF rngc <> 0 or rngc.offset(,1) <> 0
The muliplication is the substitute for the OR statement above


Regards
Claus B.
 
Hi Howard,

Am Sun, 19 Jan 2014 08:34:11 +0100 schrieb Claus Busch:

sorry, typo
IF you multiply to values and one of them is 0 the result = 0
^^^^
if you multiply two values and one of them is 0 the result is 0


Regards
Claus B.
 
Hi Howard,



Am Sat, 18 Jan 2014 22:06:35 -0800 (PST) schrieb L. Howard:






both cells rngC and rngC.Offset(,1) should be NOT zero to change the

cell value in column 46.

IF you multiply to values and one of them is 0 the result = 0

So it is the same as writing

IF rngc <> 0 or rngc.offset(,1) <> 0

The muliplication is the substitute for the OR statement above





Regards

Claus B.

Okay thanks. That would be the reason for the type mismatch, trying to multiply text.

Appreciate it.

Howard
 
Back
Top