Solved

coding if logic on number pattern

Posted on 2011-03-16
6
496 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

718 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