Solved

coding if logic on number pattern

Posted on 2011-03-16
6
494 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need VBA code to create all combinations of a routing. 30 74
question on substitute function 2 27
Conditional fromatting formula 29 33
Tricky shapes formula part 2 4 21
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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 will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

733 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