Quick Simple Newbie Question

Alfred12

New Member
Joined
Feb 28, 2011
Messages
15
Hi all --

Can someone please tell me what is wrong with this line of code:

If Cells(i, 4).Value = 1 Then

This line appears in a for next loop being counted by the variable "i". The idea is to look at the value in column D in all the rows, and if the cell contains the number 1, the "then" part is executed.

It compiles fine, and I've got messages inserted so that I know that this line is being executed. But it is not finding my "1"s to trigger the "then" action. (And in my test cases I certainly have some "1"s in the D column.) What super-basic obvious thing am i missing?

It is as if there is no tutorial basic enough for me!

Thanks!

Alfred
 
All the loops appear to be working fine -- that is, it is counting through variable S and i, and it is walking through each sheet as it should. But I can never get the second test message to show up. In other words the "if" statement" is apparently never getting triggered.

Very frustrating. I feel like I must be overlooking something silly and obvious.

Alfred.
 
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Could it be because the values in column D are the result of a formula? Do I need to do something different in that case, as opposed to if I just entered the numbers manually into that column?

If Cells(i, 4).Value = 1 Then
 
Upvote 0
Ok -- please disregard this thread. I've made a lot of progress on my own. I've moved on to a new set of issues, and perhaps I'll ask about those if I cannot crack them myself.

Thanks again!
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top