# Finding Two Patterns In Column And Doing Calculations Depending On Pattern Order Found

Apr 30, 2013

I'm attempting to do work on pattern detection and actions based on how said patterns occur in a column. Here is what I would like excel to do for me:

Code:
Pattern W1

Example A1=A , A2=A , A3=B

Pattern L1 Consecutive "A" 3 or more

Example A4=A , A5=A , A6=A

Triggers on specific events:

While L1 tracking variable = 0 -- If L1 is found, mark a variable to -2 then set the corresponding cell in the column over to the value of the variable (-2)

While L1 tracking variable < 0 -- If consecutive L1s are found one after another, then (on each consecutive occurence) multiply the variable by 3, then set the corresponding cell in the column over to the value of the variable

If W1 is found while L1's variable is < 0, then multiply the value of the L1 tracking variable by -1 and add 1, then set the corresponding cell in the column over to the value of the L1 variable, then set L1's tracking variable to 0

If W1 is found while L1's variable is = 0, then set the corresponding cell in the column over to the value of 1

All data is in one column.

## Fill Handle Pattern (not Finding My Pattern)

Jan 31, 2007

Pre-requisite: I would consider myself to be very poor with excel, based on what I've read on this forum and found on my web-searches. I have a worksheet that has a list of data on the left going vertically, then a summary of this data going horizontally across the top. It is not arranged in such a way that transposing the data will do what I want. I am pulling the 5th word out of the title of each block of the vertical data and need to show this word on the horizontal section.

When I use this formula to pull the 5th word: =MID(MID(MID(SUBSTITUTE(A2," ","^",4),1,256), FIND("^",SUBSTITUTE(A2," ","^",4)),256),2,FIND(" ",MID(MID(SUBSTITUTE(A2," ","^",4),1,256),FIND("^",SUBSTITUTE(A2," ","^",4)),256))-2)

I need to increase A2 to A30, then A58 (up by 28 every time) in every instance in that formula. The fill handle increases the values by 1, instead of 28 (even if I do 3 or 4 instances manually) How do I do this? I've run into this problem in other scenarios, and there HAS to be a way to get around it.

## Excel VBA - Returning String Found In Regex Pattern

Jun 18, 2014

I have a string and a pattern. If a substring of the string is found in the pattern, the string is no longer valid. I would like to return a message stating which substring was found in the pattern.

String: K22+L09+P88+Q12+J56
Pattern: (N75|X02|A21|U67|L09|...)
Output Should Be: "J56 is an invalid code. Blah-Blah"

Code to test string against pattern:

Code:
Function Test_OPC(sCode, sPattern) As Boolean
Dim RegX As Object
Dim RegMC

[Code]....

## Run VBA Macros In Specific Order, Turn Off Calculations & Force Calculation Of Range

Apr 22, 2009

I have a VBA method that goes thru and calculates a bunch of stuff and puts this calculated info into a static data structure. This method is called 'setProjectInfo()'. This method is reliant on values on my worksheets, So as the user makes changes to the worksheet, I want setProjectInfo() to get called so it refreshes the data structure with updated information. I then have a bunch of helper methods to access different parts of this data structure. These helper methods are used in the formulae of a bunch of cells on a worksheet (ie '=getPercentComplete(period)', etc, etc).

This is all working well except for one thing. Sometimes the helper methods get called BEFORE setProjectInfo() gets called.. So, the helper methods return stale information. I can only get around this by manually recalculating the spreadsheet again. setProjectInfo() does enough stuff and takes a long enough time that I don't want to have to call it at the top of each helper method.

I've put the call to setProjectInfo() in a cell formula at the top of the my spreadsheet in hopes that Excel would know enough to call it first.. But that does not seem to work. Net, how can I get VBA to always call setProjectInfo() BEFORE it calls any other VBA methods?

## Updating Values In Variable Ranges Based On Repeating Patterns In A Column

Jul 6, 2006

I have a list of two columns. Here’s an example. The left most column provides the row number.

_ A B
1 1 0
2 2 1
3 2 1
4 3 2
5 4 2.5
6 5 4
7 1 0
8 1 0
9 2 2

Whenever there are two repeating numbers in column one, I want to reduce certain numbers in column 2 by a certain amount. The amount is determined by half the difference between the number in column B corresponding to the second repeated number and the number in column B corresponding to the row after the second repeating number. The range of numbers that are to be reduced begins with the row after the second repeating number and ends with the last row before number one appears in column A. The values in column A are integers, always starting with one. For example, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 4, 5.

For the above example, after finding the repeating number two’s at A2 and A3, it would reduce B4 through B6 by half the difference between B3 and B4 (1/2). The values for B4 through B6 would be updated in column B. The same for the next repeated numbers, which is one at A7 and A8. Half the difference between B8 and B9 is 1.

Here’s what the updated list would look like:

1 1 0
2 2 1
3 2 1
4 3 1.5
5 4 2
6 5 3.5
7 1 0
8 1 0
9 2 1

## Getting Duplicated Values Depending On Rank Order

May 28, 2009

So, I have some names and values. Rank function give me order for those values.
Small function gives me ascending order. I want to get first n (let say 5) values back next to each other but can't use VLOOKUP function because sometimes I get duplicates (red numbers).

If there is more same numbersthat small function returns... It need to give me all of them, no matter 5 is limit. how to get back values of rank function that are duplicated. Book1.xls

## Re-Order Columns Based On Column Order Of Another Worksheet

Mar 1, 2008

I need a way to re-order an excel worksheets columns based on another worksheet.

Data is extracted from a database into excel however users can configure the columns in the initial system. to how they like This causes problems when the data is copied into an excel spreadsheet I have created as the data copied will not be in the same column order as is required.

How can i reorder the columns without physically having to cut and paste the columns to match?

I have attached a sample spreadsheet.

You will see on the spreadsheet that 'fixed columns' is the order that i require the data however 'variable columns' is not in the same order.

## Finding File Name By Numerical Order?

Sep 12, 2012

I have an excel sheet that will create a standard filing system.

in a folder there are folders numbered like this:

"ENQ 0123, ENQ 0124" and go up 1 digit at a time.

there are hundereds in this folder. I would just like to know if there is a quick way of finding the latest one so i can then tell my code to generate the next one.

## Finding The MAX In A Group Of Cell Depending On A Criteria

Jun 25, 2007

I'm trying to find a way that I could get the MAX value in a group of cells depending on a critieria. The situation is that I have a list of numbers and a list of dates parallel to it. I would like to find the MAX for, say, the numbers corresponding to the month of June. I would like to be able to change the month and get the MAX for each month on request.

Eg.
18-MAY-2007 600
01-JUN-2007 500
02-JUN-2007 400
28-JUN-2007 600
12-JUL-2007 700
17-JUL-2007 200

I need formula that will give me "600" if the month I want is June. Ideally I would not want to have to filter the data, so SUBTOTAL would probably not work for me.

## Continue Vertical Pattern On Adjacent Column

Apr 10, 2014

I am trying to make printable book labels in one worksheet based off of values from another. The labels that I have are standard address sized and come in sheets with 3 columns and 10 rows. My "label" worksheet has 5 columns (with B:B and D:D as "spacers") I made a "calculation" worksheet that simply runs the equation I want to use for the labels from A1:A1000. On the "label" worksheet, I have this formula in cell A1:

=IF('Label Calculations'!\$A1="","",'Label Calculations'!\$A1)

This way, it won't return 0s for blank cells from the "calculations" worksheet. I dragged down the formula to cell A10, but would like to continue the pattern so that cell C1 would be:

=IF('Label Calculations'!\$A11="","",'Label Calculations'!\$A11)

and cell E1 would be:

=IF('Label Calculations'!\$A21="","",'Label Calculations'!\$A21)

and the pattern would continue with cell A11 with the formula:

=IF('Label Calculations'!\$A31="","",'Label Calculations'!\$A31)

Then cell B11 would be 41, C11 would be 51, A21 would be 61, etc.

I can do it manually by adding the function in the top row of each "page" (A1,C1,E1 then A11,C11,E11...) and dragging them down each "page." However, I may end up with 20 some pages of labels. I feel like there should be an easier way I can do this.

## Repetitive Pattern With Column Letters And Numbers

Jul 30, 2014

how can I modify the formula below so that after every row (i+60) the letter D changes to E then F, then G..... and so on. I want the following with the formula below:

=MAX(\$D\$2:\$D\$61)
=MAX(\$E\$62:\$E\$121)
=MAX(\$F\$122:\$F\$181)

and so on...

[Code] .....

## Single Column To Repeating Pattern Of Columns?

Nov 22, 2013

CartonNo1

ProductNo1

LotNo1

LotNo2

CartonNo2

ProductNo1

LotNo3

LotNo4

In the above (repeating for say, 50 or more cartons), is there a way with a macro(I know nothing about) or pivot table(see macro) to get the following format/result?

CartonNo1
ProductNo1
LotNo1

CartonNo1
ProductNo1
LotNo2

[code].....

## Parse Through A Column Of Numbers And Find A Repeating Pattern

Mar 13, 2009

I need a function or VB code to parse through a column of numbers and find a repeating pattern. The column has some initial numbers that do not fit the pattern and I need those returned along with the repeating pattern.

## How To Find Matching Pattern And Retrieve Data From Adjacent Column

Jun 1, 2014

I need to find and match patterns of strings in a column and fetch data from the adjacent column. I've attached a sample workbook with my sample data.

How can I find the appropriate matching pattern and fetch and fill data from the adjacent column from my source table to destination? I tried the string functions available and used SEARCH function to match the pattern and check whether it is available. However, when the pattern is found, how can I fetch the adjacent column ?

My attempt to code a formula using SUBSTITUTE, MID and SEARCH functions. Below is the monster formula I wrote - it works and returns 1 when the pattern is found.

Formula:

I need to return the matching pattern that is found. And with it the corresponding adjacent cell's value.

Attached File : Find_Pattern_Match_and_Fetch.xlsx

## Select The Names In Column 3 Of Rp1 And Printout In The Same Or A New Sheet Every Row Containing This Name From The Pattern Spreadsheet

Jun 11, 2006

I have two sheets,one called pattern of about 25000 rows and one called rp1,
which is a fresh sheet downloaded each night from the web. What I want to do is select the names in column 3 of rp1 and printout in the same or a new sheet every row containing this name from the pattern spreadsheet.So for every horse named in col c,I want its complete record,could be 1 row or maybe up to 20 rows output,from the pattern worksheet(for each). They will all be underneath each other. I simply want excel to extract all the data belong to these names in rp 1 from the pattern large sheet. The names are in col r of the pattern sheet.

## Use Two Different Calculations Based On ID Number In Column

Jun 28, 2012

I have a list in Excel with several hundred 8 digit ID numbers in column D. Column C contains the total number of hours the student employee worked. Column E needs to calculate using two different equations depending on if the ID number in column D is a manager's. If the ID number is an employee the total hours worked is divided by 8. IF the ID number represents a manager the total hours worked is divided by 4. I've attempted this by using an array for the manager ID list and also using VLookup without success.

In essence I need to loop through column D, check which type of ID number is present, and then enter the correct formula in column E.

## Removing Values From Column A That Are Found In Column C?

Jun 5, 2013

I need to remove values from column A that are present in column C without modifying the order in column B. To be more explicit below is an example:

Column A---------Column B-------Column C

5230400----------81,50----------1660000
3275500----------78,00----------6245700
2856300----------47,50----------5230400
1879800----------62,50----------2497900
2124300----------99,00----------1879800
2497900----------65,00
4826900----------77,50
2124200----------34,00
6245700----------61,50
3324400----------86,00
1660000----------53,00

Column A represents 600 materials.

Column B represents 600 prices. (different for each material)

Column C represents 107 materials that are present in column A and have to be removed along with their prices in column B.

Now i want to remove the materials that are in column A and C along with their prices, so i won't damage the order in the file.Meaning if i delete a row in A and shift the other materials up or down, and in the same time column B remains unchanged, the remaining materials will have different prices...and that's not good.

## Calculations On First Lines For Entire Groups Of Data In Single Column?

Feb 25, 2014

I'm looking to do some simple maths with ranges in Excel but I'd like a way to be able to input all these formulas automatically although I am pretty sure a single formula per column could do it all automatically. I've got to put the sums in AD to AF on the first line of each location, but the maths is for the entire location's range.

[URL]

## Create Sequence - Put Order In Second Column Of Item That Is In First Column

Dec 28, 2011

I need to put the order in the second column of the item that is in the first column.

In the last line item Computer is recorded for the third time.

MATERIALSSEQUENCEComputer1Computer2Mouse1Mouse2Computer3

## How To Delete Patterns From Data

Jul 29, 2013

I have the following code for identifying the 1,3,2 patterns from sheet1 and it copy pastes those rows into sheet2. I was wondering if there is a way to modify this code to delete those patterns once it has identified them instead of pasting them into sheet2. In other word,s sheet2 needs to contain every other data except those identified patterns.

VB:

Sub test()
Dim myPtn As String, txt As String, m As Object, n As Long, LastR As Range
Dim ws1 As Worksheet, ws2 As Worksheet, myStep As Long, i As Long, t As Long
myStep = 10000 '<- change here if needed.
Set ws1 = Sheets("sheet1")
Set ws2 = Sheets("sheet2")

[Code]...

## Identify And Number Patterns

Nov 3, 2013

A person on this board did this for me with this so far and I need to be able to view more than 16 rows. I would like to view all the rows it finds. I have 62,000 rows on information this far and will exceed 500,000 so you can see my need to see all involved to save hours of sifting through data. I would also like a place up top near the box (column G.H)(3,4,5) another box for me to enter a new number combination to search. Presently I have to go through the data to find the first one which is also time consuming. I would like to be able to put say for example in the area I am mentioning:

2 6
4
2 8

## Weekend Shift Patterns

Jan 19, 2010

I'm trying to divide the hours between 2 given times in blocks:

i.e.: monday 0600 - 1400 = 8 hrs

2400-0700 [mon - fri] = 1
0700-1800 [mon - fri] = 7
1800-2400 [mon - fri] = 0

0000-2400 [weekend]

I got the first 3 blocks working but got stuck with the 4th one.

It should count only those hours between saturday morning 0000 and sunday night 2400 if it concerns a weekend day. and actually these hours should not be calculated in the first 3 time blocks.

## Regular Expressions Patterns

Sep 24, 2009

Hope the title isn't too broad. Every time I think I have got to grips with RegExp I get stuck on something apparently quite simple. So, I have a few queries so I hope OK to bundle them together.

1. How do I remove the word 'of' only if it occurs after certain other words (the other words should also go). E.g.

"Vale of White Horse" should stay the same
"Borough of Lambeth" should become "Lambeth" (because 'of' after 'Borough')

I tried "Borough(sof*)" but that doesn't remove either word.

2. How do I remove everything after a '/' (inclusive)?
I have tried "/sw+" which removes the first word after '/' but there could be other words

3. How do I remove everything inside brackets (inclusive)?

## Formulas Recognizing The Patterns

Aug 15, 2008

I am trying to do an "if" statment to look in every 23rd cell to see if it is greater than 0. if it is it populates what is in that cell. That is fine...

The problem is i want to create the "if" statement just a couple of time manually, than drag it down 300 rows and have it look every 23 cells. It does not recognize the pattern???

## Average Column Depending On Values In Another Column

May 17, 2009

I have tried a few other examples in previous threads that use COUNTIF and ISERROR but I just can't get it right.

Basically I want to average the cells in column J (J2:J6,J8:J12,J14:J18, etc).
My aim here is to determine the average value for each day (Averaging 0 values in this instance is OK).

Now, the date in column A (A2:A6,A8:A12,A14:A18, etc) sometimes returns a blank value, depending on the day of the week (see attached example). This is because, in the full version of the workbook, I have Column A date linked to a perpetual calendar and therefore the dates can change cells depending on the year.

For the Date Cells that return a blank value, I do not want the AVERAGE equation to include the 0 value on these days.

For an example I have attached a month of February where there are blank date cells at either end of the column.

## Filled Patterns For Xy Chart Lines

Jun 6, 2007

I have an xy chart for which I would like to format the lines to be different patterns beyond those available in the format series dialog. I recognise that this will mean using VBA and I am happy to do that. I would like to be able to use patterns in the same way as they are used in a column chart.

I recorded a macro to see which properties were changed when the patterns are selected in the dialog for the xy chart and it is clear that it is only the LineStyle of the border and that there is no interior.

With Selection.Border
.ColorIndex = 57
.Weight = xlMedium
.LineStyle = xlGray25
End With

This would explain why when I use debug.print ser.Interior.Pattern I get -4105 or if I change ser.Fill.Forecolor etc it has no effect.

Is there any way to use user defined patterns to colour the lines in the same way as in a histogram/coloumn chart?

## Excel 2007 :: Time Difference Calculations And Automatic Insertion Of Text In Blank Column

Jan 4, 2014

Please find attached a daily copy of a spreadsheet that is used to monitor train running times.

The columns on the left - "Serv No, Serv Start Date,Train No:, Scheduled Arrival, Scheduled Depart" are provided to us automatically and the underlying cell formatting/formula cannot be changed. This information is cut directly from a daily report sent to us the previous day. The cell formatting for the start date is custom - dd-mm-yyyy hh:mm.

The sheet is usually locked out with user access only to the left hand side to cut and paste train times in and the input columns on the right hand side. User has no requirement to adjust any details in the left had column apart from to add additional trains at the bottom is need be. I have left the loaded sheet blank and complete with all underlying cell formatting, conditional formatting and formulas intact for you to play with.

Both sheets essentially do the same thing so whatever formula changes are made to the empty sheet can be adapted for the loaded sheet.

For simplicity, I will focus on the empty sheet. What I am mucking around with is having the user input the train arrival time in the "Actual Arrival" column - (column F)

What I am looking at then making occur is the spreadsheet automatically filling the adjacent columns with the appropriate text and calculations.

To do this excel needs to compare column the number (cell input is text formatted) as a number with the arrival time in column G. It then needs to calculate if the train is Early (16 minutes or more before scheduled arrival), on time (+/- 15 minutes either side of scheduled arrival) or late (16 minutes or more after scheduled). It then needs to automatically place the letter "E", "O" or "L" in column K and the time differential in column L.

My problem is two fold.

Firstly, I cannot seem to make the spreadsheet automatically enter a letter into column K depending on the above conditions.

Secondly, I have had limited success in having the spreadsheet compare column J with column F and working out the differential. However, this only works if the time remains linear. IE only if the train runs on time or late. It gives an incorrect time differential if the train is early. I will attach this spreadsheet tomorrow as an add on to this post.

DAILY TRAIN RUNNING.xlsxâ€Ž

## Creating Patterns For Auto Fill To Follow?

Aug 20, 2014

I'm trying to create an auto fill pattern to match B4-M4 then repeat with B5-M5 and continue to 350.

So for example, I'd like to manually enter "B4,C4,D4,E4,F4,G4,H4,I4,J4,K4,L4,M4,B5,C5,D5,E5,F5,G5,H5,I5,J5,K5,L5,M5" into column A and drag the auto fill box down until I've repeated the pattern to match all the way to M350.

Is this possible? I tried just entering the pattern as I've posted and dragging the auto fill down, but it doesn't fill the numbers properly and ends up with a strange pattern.

## How To Match Data Patterns Across Multiple Columns

Apr 14, 2009

I am using Excel 2007 and I need to search for data patterns that are spread across many columns. I am not sure how to search so that criteria is met across all the columns concurrently.

For example

I am interested in data that matches the following criteria ;

Column B has the value 55
Column C has the value 70
Column D has the value 80

Rows of interest are when all the criteria in columns B,C,D are met at the same time (e.g 55 in B, 70 in C and 80 in D).

## Cyclical Patterns - Highlighting Repeating Rows

Oct 10, 2011

I have created a spreadsheet to find cyclical patterns and my next task was to sort these patterns from highest value to lowest.

Next I need to start from the first row of the sorted spreadsheet and find the first row working down that repeats. Once I find his row I have to stop the search and highlight both the original and repeated rows. If the first row has no repeat it has to move to the second row and do the same operation until it finds a row that does repeat and so on.