Solved

coding if logic on number pattern

Posted on 2011-03-16
6
492 Views
Last Modified: 2012-05-11
Dear experts,

I am a bit new to Excel 2007 and I am trying to figure out how to create a formula to add 7 to the previous number if the number in the tens place is not the same as the previous number in the tens place. If it is then add 17 to the code. Here is a sample number pattern:

0026
0033
0040
0057
0064
0071
0088
0095
0101
0118
0125
0132
0149
0156
0163
0170
0187
0194
0200

I am entering a ton of certified mail tickets and seems the last four of the ticket number has this pattern. Knowing a formula to autofill would save me a ton of time.

I have attached a sample spreadhsheet. I could easily code a formula to add seven but get stuck when I try to if logic to check the tens place.

Thanks!



Certified-Reciepts.xlsx
0
Comment
Question by:shogun5
  • 3
  • 2
6 Comments
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 35152949
See the attached. Did I interpret your question correctly?

Kevin
Certified-Reciepts.xlsx
0
 

Author Comment

by:shogun5
ID: 35152961
zorvek:

No. Please see screenshot. The tens place apparently cannot repeat. I suppose if the formula is correct you could type 0026 in the first cell and then use the formula populate subsequent cells and the numbers under D should be identical.
excel-screenshot.jpg
0
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 250 total points
ID: 35152968
This should work:

   =D2+7+IF(TRUNC((D2+7)/10)-TRUNC(D2/100)*100=TRUNC(D2/10)-TRUNC(D2/100)*100,10,0)

Kevin
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Closing Comment

by:shogun5
ID: 35152974
Cool! Thanks!
0
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 35152975
See attached.

Kevin
Certified-Reciepts.xlsx
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 35152983
Here's a shorter option

=D2+7+(MOD(D2,10)<3)*10

regards, barry
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now