Testing for years ending 7

joeljoel

New Member
Joined
Feb 8, 2010
Messages
21
I have a couple hundred years worth of data and the years are in the rows of Column B. I need to test if the year ends in 7, so 1807, 1817, etc and if so enter a -1, otherwise leave blank. I would think this should be easy, but I cannot figure it out, other than lsiting all the years ending 7 in an if statement. There must be an easier way. Thanks!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Thanks. Works like a charm. Can you teach me to fish, though?

If you could explain this a bit it would help in the future as I will likely need to look for years in multiples of 2 and multiples of 4 as well.

Thank you!
 
Upvote 0
What the formula is doing is saying that the value of the cell is (If the value of the remainder of b1/10 is 7) is -1, if not then the value is "" or blank (because there is nothing between the quotes.
the second formula is if the right most letter/number is 7, then the value is -1 if not then blank
 
Upvote 0
Thanks Learninman. I think I get it. I like the RIGHT function.

So if I understand MOD correctly, to test if a date in column B is an election year, I can write something like IF(MOD(B1,4)=0,1,"") since election years (in the US) are all divisible by 4 and even mid term election years are not?

Just tested it quickly and that works. This is fanatastic. Will make this project go so much more quickly and efficiently.

Thank you so much!!
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,919
Members
452,949
Latest member
beartooth91

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