# SUMIF- Column Of Contract Numbers Of Varying Length

Mar 27, 2009

I have a column of contract numbers of varying length. I want to run a sumif of all of the values on my reference sheet that have the contract number beginning with the contract number in my listing. All of the the contract values in my reference sheet are very long. Since the numbers I am working with vary in length, i don't know how to match this string in the sumif function

I want something like this

=SUMIF('Reference Sheet!\$A\$5:\$A\$13410,LEFT("", LEN('Select Contracts'!\$C6))='Select Contracts'!\$C6,'FINALIZED DATA'!\$H\$5:\$H\$13410)

Is there a way to refer to the range in the sumif function,

## Extract Two Separate Numbers Of Varying Length From Text Field

May 24, 2014

a formula to extract the numbers into two separate fields. The text may vary in length and the numbers vary in length also from 1 digit to 2,000,000.

Data in A1 is as follows:-

## Combine Rows Of Varying Length And Varying Number Of Occurrences

Jun 28, 2012

There are 11,000 rows and 4,000 are unique. The goal is to merge the data down to the 4,000 records. Each of the unique entries shows up 1 to 15 times.

In trying to solve this, I wonder if I should break this down into the different # of occurances and implement specific solutions. e.g., There are

5700 entries that show up 2x
504 that show up 3x
24 that show up 12x

## Computing With Last 252 Rows Of Varying Length Column

Nov 26, 2009

Using Excel 2003, Column E has a varying and unpredictable number of rows, which only the final 252 rows are of significance. I need to compute the following formulas, here written in English as I can't determine the proper terminology to accomplish this task in Excel:

Final Row with a number in Column E/average (final 252 rows with numbers in column E)+

Final Row with a number in Column E/average (final 126 rows with numbers in column E)+

Final Row with a number in Column E/average (final 63 rows with numbers in column E)

Once again, what makes this not straightforward for me is the column may have wildly varying numbers of rows.

## Creating Macro To Calculate Columns With Varying Length

May 2, 2012

I have a column of data where the seperate entities are divided by blank rows. for example: i need to calculate sum(G3:G15) then skip the blank row (G16) and calculate the next group, say sum(G17:G50) and export that import to a new worksheet.

The issue is that the column lengths vary from day to day so the blank rows will not be in the same position.

## Bring Data From Sheets Of Varying Length To One Main Sheet

Apr 17, 2012

I have a workbook with several sheets of varying length (amount of columns). The length of each sheet changes every week. I want particular data from the sheets to come together on one sheet in as organized a fashion as is possible. I'm currently losing my mind copying and pasting every week when I need to update the thing.

## Depending On Value Of One Cell - Pull A Set Of Data From Another Page Varying Length / Width

Aug 12, 2014

I have drop drown menus that allow you to select 1 of 3 choices and based on those a second set which lists the options for the first three (subset). Now depending on the second value I need to pull a set of x y coordinates that can be of varying length. '

Example

Drop down menu 1 1560, 1669, 1554. Drop down menu 2 1560-1,2,3,4 1669-a,b,c,d. This has been done now lets say I select 1560-1. I need the following to be pulled from a list, the data is a block.

1.00 1.543
1.23 -1.25
0.54 -2.75

This can be of any length.

## Concatenate Varying Numbers Of Cells Based On Duplicates Found In Separate Column

Jul 25, 2011

I need to concatenate varying numbers of cells based on duplicates found in a separate column, but I'm not sure how to approach it. I have 41,000+ rows of data, so I have to find a formula.

Example:

1AB2Denton, PaulFB357D4D3OwensTest, MarcyFB539F934Brennan,
JosephFB539F935Bowser, AmyFB539F936LaRock, ChuckFB667D3B

Based on duplicates in column B, I want to combine the data in column A into one cell. The duplicates in column B could be only 2, or could be 20+.

## Separate Contents Of Column Of Numbers Based On Their Length?

Mar 5, 2013

I have a spreadsheet with numbers like this

9404388
9404374
9404391
9405695
38301663
9409724
1791016
9435145
9530758
9440464
9441182
71000569
9467438

There are a thousand numbers like this, I was wondering how I can move the cells with 7 numbers to the right column, and keep the cells with 8 numbers where they are (or move them to the 3rd column to the right)

## Sumif Of Varying Range Of Cells

Apr 11, 2012

I'm trying to sum a varying range of cells based on conditions in another column. right now im trying =SUMIF(B:B, "Active", C4:C10)

The number it is returning is not correct and I'm not sure whats wrong. Also, is there a way to allow the range of cells to vary? Like if I wanted to insert a row and have it included in the sum.

## Pull Varying Length Text From Cell Text

Jul 2, 2007

I need to find text within middle of a string.
Character before required text is say AAA
Character after required text is say BBB
Text required can vary in length.
Extract text and place in another column.

All text in a single column, required text not in every line. but
does repeat.

## Sorting Numbers Of Varying Lengths

Aug 15, 2012

I am trying to do a VLOOKUP using a list based on our Part numbers in Excel 2007. When I do a normal sort it groups the numbers 1 thru 9 by the number of digits, giving me multiple list of 1 thru 9. When I do my lookup it will not find the shorter numbers. Is there some way to sort these Part numbers in order regardless of the number of digits?

## Macro To Subtotal Varying Lists Of Numbers

Apr 17, 2014

I am fairly new to excel and I am having trouble trying to get a sub total function to work for me. I need the subtotal to for a list of about 20 columns in one line with a varying amount of rows. So the subtotal must stop when there is a blank at the top. I can get the macro to find the totals A on the spreadsheet and then offset to beneath the columns of numbers but the sub total formulas takes in every number. Here is the example:

456.00
8,798.00

45,465.00
789,789.00

45,465.00
789,789.00

45,646.00
7,897.00

Totals A

[Code] ........

## Macro, Autofill On Varying Numbers Of Rows

Jan 13, 2003

I am putting together a macro to import a CSV file onto excel. I will be manipulating columns of data (concatinating some, dividing by 100 etc.)

What I am having trouble with is that each file imported will have different number of rows.
I tried, in recording a macro, to use autofill (entered formula and double-click fill handle to drop the fourmula into each cell) hoping this would show me how to do it but alas, it just coded the range as the starting and stopping cells (didn't show a count formula or some such.

## Varying Validation Drop-downs Based On Varying Cell Values

Aug 7, 2013

I am attempting to have cells in Column 'U' deliver different drop-down menus based on the corresponding value in column 'D'. I have created 7 named lists:

List_117G
List_152
List_JMET
List_XBAND
List_PACWIND
List_VORTEX
List_ROVER

Those lists will be called up based on 7 values in column “D”:
“G”
“152”
“J”
“X”
“D/E”
“V”
“R”

So far I have only been able to get this to work for the first category “G”. When I change the value of column “D” from “G” to “152” I no longer get a drop-down. Here is the formula I am using in the List function of validation.

=IF(D6="G",List_117G,IF(D6="152",List_152,IF(D6="J",List_JMET,IF(D6="X",List_XBAND,
IF(D6="D/E",List_PACWIND,IF(D6="V",List_VORTEX,IF(D6="R",List_ROVER,)))))))

## VBA - Call Macros With Varying Names And On Varying Modules

Oct 2, 2013

I want to call a macro with a varying name that is within a module with the same name.

I have a module called Test1 and within this, a macro name called test1
I have a module called Test2 and within this, a macro name called test2
etc

On another module called Test8 (with the macro called Test8), this Test8 macro will call either Test1 or Test2 or Test3 etc depending on what I choose in an excel spreadsheet. So on sheet1, cell A1, there is a drop down with the options Test1 or Test2 or Test3 etc.

The following works to run the macro test1 from module test1 (when it does not vary i.e. i physically put in the name of the macro myself):

Sub Test3()
Test1.Test1
End Sub

The following works to run the macro test2 from module test2 (when it does not vary i.e. i physically put in the name of the macro myself):

Sub Test3()
Test2.Test2
End Sub
etc

However, if I try it so that the calling of the macro varies as below , it does not work:

Sub Test3()
MacroToCall = Sheets("Sheet1").Range("A1").Value
MacroToCall.MacroToCall
End Sub

## Dividing Dollar Amounts Unevenly Into Varying Numbers Of Cells/columns

Dec 10, 2009

I have dollar amounts that I need to distribute amongst varying numbers of columns and not have have the total distributed be over or under the original amount by any number of cents. When I simply divide the dollar amount by the number of columns, the total of those columns can sometimes be more or less than the original dollar amount by a few cents.

e.g.
Dollar # of A B C All Columns
Amount Columns Total
--------------------------------------------------------------------
\$25.05 2 \$12.53 \$12.53 \$25.06
\$11.47 3 \$ 3.82 \$ 3.82 \$ 3.82 \$11.46
\$25.05 divided into 2 columns gives \$12.53 in Column A and \$12.53 in Column B. Total of Columns A and B is \$25.06. Over by a penny.

\$11.47 divided into 3 columns gives \$3.82 in Columns A through C. Total of Columns A through C is \$41.46. Under by a penny.

I know I could simply always add or take away the pennies from one column, but I would prefer the process to be random or formulated in such a way that the Column to which the extra pennies are added to or taken away from differs in order to be "fair to each column".

## Length Equivalent For Numbers

Apr 18, 2007

When I tried len(nYear) where nYear is a number like 2006, I don't get the number of characters in the number. I know that's confusing strings with numbers, but...

Is there a VBA function that returns the number of numbers deep in an integer; ex. if nYear = 2006, the function would return 4?

I could easily do a < or > line of code, but I'm just curious if there's another way to do it.

## Get Same Length Series Of Numbers From Different Columns In The Same Cell?

Oct 2, 2012

solve this task with a formula or a macro?

I have this strange number data stored by columns. Each cell contains one number series of different length from 1 to 13.

Needed results 1, Needed results 2
7409998765 7409998766 , 9998766567876, 7409998765 9998766 9998766 7409998766 9998766 9998766567876 9998766 9998766

I need to look-up and bring in one cell for each row only the 10 length numbers separated by space and in another cell the 13 length numbers space separated also.

The number of columns containing data is different from row to row ( from 2 to 60)....and the rows..are thousands..

## Transpose Macro Varying Rows From 1 Column

Aug 22, 2009

I've trawled a few forums for a while now trying to find a macro that matches my specifications, or one I can adapt but so far have been unsuccessful, so here goes:

I have one column of data (col. A) of customer names and addresses each with an empty row in between them. The lines of data relating to each customer vary from 6 rows to 14 rows, then an empty row, then the next customer and so on - for several thousand rows.

I am wanting to create a macro that will transpose each customer to either their own row in sheet2, or to column B and then delete column A at the end.

All I can find is macros for a specific number of rows rather than varying. One way would be to have a code that 'pads' out those customers with fewer than 14 lines by inserting rows to make them 14, and then a code to transpose 15 rows at a time.

## SUMIF In A Column: The First Instance Of Each SUMIF

Apr 21, 2009

I have many kitchens using the same recipes. I need to distill information down until I've got a summary of how much is being made. Uploaded is a condensed version of the point in the process I'm having difficulty with. This workbook will pull information from 8 other workbooks and give me excatly what everyone made on any weekday.

And from there, with the kind help of this forum, I figured out how to do a SUMIF based on the recipe number. And it summed up all instances of 'Recipe X' being used. However, it continues to SUMIF itself all the way down the page... which is good, because of how recipes are chosen for each kitchen. However, I only need to report one instance of each recipe.

In the uploaded example (and I apologize for the colorful sheet, but it helped me double check what I was working on.) ... I only need to report the PURPLE results elsewhere... the first instance of each SUMIF.

## Macro To Sum Or Subtotal Ranges Of Varying Lengths In A Column

May 1, 2014

I've reached a point in this macro where I'm stuck with NO clue how to achieve this, or even whether it can be done. In the Before sheet below, I need to bold the cells in H & I if the word "Total" is in G. I could probably manage that part, but here's the weird part: I need to add a formula to H & I of each row with "Total" in G to sum the numbers above it, from the previous total down to the current total. But there's no telling how long each range might be on a given report; from 1 row up to 8 rows.

THEN, in the second row below the end of columns H & I, I need to put a formula totalling all of the preceding Totals

I wonder if there might be a way to tell it to put a formula in H by each cell that has "Total" in G, with the formula summing or subtotalling everything from the cell in H that has data in F to the cell just above the "Total".

Attached File : Acct Activity.xlsx‎

## Summing/averaging A Column Of Varying Number Of Rows

May 18, 2007

how to code VB to where when data is sorted a formula can be placed at the bottom a column to sum or average the above data?

I have tried relational positioning e.g

each time a row is created, integer n5 = n5 + 1

Application.CutCopyMode = False
ActiveCell.Offset(rowoffset:=1, columnOffset:=12).Select
ActiveCell.FormulaR1C1 = "=sum(r[" - " & n5]c:r[-1]c)"
ActiveCell.Offset(rowoffset:=0, columnOffset:=7).Select
ActiveCell.FormulaR1C1 = "=average(r[" - " & n5]c:r[-1]c)"
Application.CutCopyMode = False
n5 = 0

Where n5 is augmented each time a row is created then set to 0 to count the next list

## Shorten String Length If Exceeds 31 Characters (max Sheet Name Length)

Mar 27, 2014

I've set up a filing system which saves sheets/ workbooks based on the value of a cell - Range("B1") Everything works great apart from when ThisFile String length exceeds 31 characters which you may know is the max useable character length for a sheet name - I had no idea! 8-0

Is there a way i can check if string length exceeds 31 characters then, if it does, shorten it to 31 characters?

[Code] .....

## Formula Code To Find Arc Length From Chord Length

Sep 4, 2012

How to create a code formula to calculate the arc length from a given chord length?

If you know the radius of the major circle.

Say the chord is 50mm and major circle dia is 72mm (radius 36mm)

arc from chord.jpg

## Give Cell A Value Based On Length Of Row (variable Row Length)

Jan 9, 2010

My worksheet contains data with the reaction times on a psychological test. Each respondent in the test has 280 rows in my excel sheet.

The 'perfect' length of the row, is from A to M. When an error is made in the test, the length of the row will increase. So the error length can be A to AA.

For me it is important to analyse the error. So I would like to give a perfect row length, the value 1, and an error row length a value 2.

So, in conclusion:

If:
Cell length = A1 - M1? --> Copy A1 B1 C1 (A B Cof that row) to Sheet3, and give D1 in sheet 3 the value 1

Cell length >= A1 - M1? --> Copy A1 B1 C1 (A B C of that row) to Sheet3, and give D1 in sheet 3 the value 2

## Expand And Contract Group On Click

Jul 7, 2013

I have an excel file where I have a grouping of cells. I don't trust some people to expand and contract the grouping via the tiny buttons on the left of the screen as some people using this program will have no prior experience with excel so it needs to be very simple and intuitive.

On clicking a specific cell I would like the grouping to expand if it is already contracted, and contract if it is already expanded. I would also like for this to happen outside of using VB because I hate those enable/disable macro options when you first open excel but I am willing to use VB if necessary.

## Macro Code To Average Multiple List Of Varying Column Ranges

Apr 4, 2009

I have a spreadsheet that has two different data sources (i.e., A and B). The amounts of these data sources (i.e., the number of columns) varies from sheet to sheet. I have to calculate the averages of these data sources independently and together. Because this data is spread across twenty or more spreadsheets, these calculations can be time-consuming. I want to do the following:
1. Locate the last occurrence of the first data source "A" in row and then insert a column after that cell.
2. In that cell, I want to get the average of each data source for each row of data (i.e., there are always 19 rows of data).
I want to do the same two steps for the second data source "B". Then, I want to insert a column after the "B" average and this column will be used to get an average of each row of data from A and B together. Please keep in mind that the number of data sources for A and B varies from sheet to sheet.
So far, I am working on code to try to " find" the text in a range (i.e., find the last instance of "A"), but I cannot figure out how to get it to get it to stop at the last occurrence and then insert a column. I have some ideas about how to calculate the average, but any of yours are much appreciated.
Also, the row with the type of data (i.e., A or B) is named because this function is part of a larger macro. Therefore, it is relatively easy to get to it.
I have attached a version of the file that displays how I want it to look.
The code I have thus far is:

Cells.Find(What:=A, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate

## SUM A Column With Unknown Length

Jun 26, 2012

Trying to sum up a column that has an unknown length. This is a canned Excel form that is saved within a software system and is used to create customized documents. Usually, I would enter the table name.field name in a cell to pull the data from various parts of the system.

In this case, that data resides in AA234 of my customized Excel sheet. When the user retrieves this doc from the system, the data could run several rows, starting from AA30 to AA255. So, in my "Total" cell, I've entered =SUM(AA1:AA255), so it will just add up whatever is in the column, regardless of how long it runs upon document generation. When I try to pull the document, I get "=SUM(#REF!)" in that field instead.

## Macro To Create New Tabs Based On A Contract Number

Apr 11, 2008

I work with contracts and have to report the sales for each contract by customer number, name, address, product code or sku, sales amount, quantity, and invoice date. Each contract number is associated with a product group and within that product group are a laundry list of product codes or skus.

Customers are often on different contracts for different products and may purchase some or all of the products on that contract. When I run a query from the system to extract this data, I get one sheet that contains 20,000 lines that have to then be sorted and seperated into different tabs based on the contract number. Keep in mind that a customer may be listed multiple times because each line in the query represents a product code and an invoice date.

I currently have a macro that will format the reporting such that it sorts the data, however, what it doesnt do is look for each instance of a particular contract number and separate it into different tabs.

So below are two examples: April and May 2008 Reports

April 2008 Report
Contract 1 contains 5,000 lines of data - extract into new tab
Contract 2 contains 5,000 lines of data - extract into new tab
Contract 3 contains 5,000 lines of data - extract into new tab
Contract 4 contains 5,000 lines of data - extract into new tab
Total lines = 20,000

May 2008 Report
Contract 1 contains 7,500 lines of data - extract into new tab
Contract 2 contains 5,500 lines of data - extract into new tab
Contract 3 contains 8,000 lines of data - extract into new tab
Contract 4 contains 9,000 lines of data - extract into new tab
Total lines = 30,000

So for the April Example, I would like excel to take this one list and break into 4 new tabs based on the contract number and carry over all of the data into that tab.

Where this may become difficult is that there may be more lines of data one month and fewer another. Im not sure if there is a function that will tell excel to stop when it reaches the last line for one contract number and to start a new tab for the next contract number. (see the month of May example)