Reputation: 259
I am trying to perform an If
statement so that, if a variable's value is equal to "Mils"
, it will do the stated function. But nothing is currently happening.
What am I doing wrong?
z = Sheet2.range("B20").value
If z = "Mils" Then
Set cx = Sheet8.range("D3", Sheet8.range("D3").End(xlDown))
For Each rng In cx
rng.value = rng.value / y
Next rng
Set cy = Sheet8.range("E3", Sheet8.range("E3").End(xlDown))
For Each rngy In cy
rngy.value = rngy.value / y
Next rngy
End If
Upvotes: 0
Views: 126
Reputation: 187
From what i am reading, your program probably ignored some of your instructions.
try this problem solving method:
1) hover your cursor over and click the code.
If z = "Mils" Then
2) click F9 to put a mark on that line
3) click the F8 key progressively ( what this key does is it runs the program till that code. so it basically shows you the flow of your program.)
4) check if F8 skipped any of your codes in :
If z = "Mils" Then
Set cx = Sheet8.range("D3", Sheet8.range("D3").End(xlDown))
For Each rng In cx
rng.value = rng.value / y
Next rng
Set cy = Sheet8.range("E3", Sheet8.range("E3").End(xlDown))
For Each rngy In cy
rngy.value = rngy.value / y
Next rngy
End If
if it skipped any steps then you should probably take a look at the skipped steps and make necessary adjustments.
Upvotes: 1