VARIABLE SUM Of Values

May 17, 2007

Using only basic formulas (no VBA then), I need to solve the problem of a VARIABLE SUM of values:

Starting always from the value 1:

- if “control” is “x”: the formula has to write in its “memory” the value 2 and in the next row the new value will be the sum of the two values (1+2), so 3;

- if “control” is “y”: in the next row we repeat 1.

From this point:

- if “x”: we add to the last value of our series another value that will be the last used value and in the next row and in the next row the new value will be the sum of the left value with the right value of the series (in this moment 1+3), so 4;

- if “y”: the formula has to delete from its “memory” the two values that formed the previous sum (in other words the external values of the series) and in the next row the new value will be the sum of the left remained value with the right remained value of the series maintained in “memory”. If remains only a value in the next row we’ll write that single value.

N.B.: if “control” is “z”: the formula must hold in “memory” the sum of values and write that sum in the next row but without considering because all the operation are “suspended”! When “control” will return to “x” or “y” operations of summing or cancelling will start again.

At the end: when everything will restart from the beginning of a new session with the value 1 and “forgetting” entirely what happened above??

There’re 3 cases:

- when all the values are deleted, in the next row will restart a new session with the value 1 “forgetting” entirely what happened above;

- when the result of the sum is >= $A$2, in the next row will restart a new session with the value 1 “forgetting” entirely what happened above;

- when the value of the column “heart” is >= $B$2, in the next row will restart a new session with the value 1 “forgetting” entirely what happened above.

Excuse my english and if you need any clarification… just ask!
No need for this in only a column, you can use all the intermediate columns you may need.
After spending 3 weeks on this I really hope that someone could help me solving this VARIABLE SUM of values.

View 9 Replies


ADVERTISEMENT

Summing Variable Values Across Variable Sheets In Multiple Columns

Jun 27, 2014

I need a macro that will create a sheet at the end of the workbook.

Sum data from a variable amount of sheets and display that data on the created sheet.

Here is a step by step:

Starting on sheet 5.

Column D has a variable amount of part numbers in it. These part numbers would be different between the ascending sheets.

Column T, U, V has an inputed number in it that would need added up across all duplicate part numbers in all the sheets.

(Note: The data would also need started on row 4. Everything above row 4 is headers)

Here is a small example:

D E T U V
13019090W Part A1
68705500 Part B1
64202900 Part C-11
59634600 Part D1
26005300W Part E1

I need the macro to start with sheet #5(starting on row 4). Check to see if there is data in column T, U or V. If there is, to create a new sheet at the end. And copy the entire line into that sheet (starting on row 4).

After that, to check every sheet after (excluding the newly created one, starting on row 4) for data in Column T, U and V. And then check for duplicates in Column D on the newly created sheet. If there is a duplicate to add/subtract that number in Column T, U and V to the SUM in column T, U and V in the newly created sheet. If there is no duplicate, to copy the entire line to the new sheet.

So that when finished. On the new sheet, you have the SUM of T, U and V for everything that has data in T, U or V for all of the previous sheets, plus the entire line of the first instance (excluding the first 4 sheets).

View 2 Replies View Related

Variable Values To Cells

Jan 9, 2007

Is it possible to have a cell populated by the value of a Variables obtained (or defined) using VBA? A message box confirms that the variable is indeed defined as desired but I would like its value used in a spreadsheet cell.

View 9 Replies View Related

Add 2 Cell Values To Variable

May 17, 2007

I run a large macro which combines and compares an Excel file with a download out of our SAP system. One of the selection criteria I have to put in is called 'Plant' and it is a single value which I select from a drop down list. (Values are 1010 1020 1030 1040). In the Macro the value is defined as:

Plant = Range("I21").Value

where I21 is the cell in which the Plant is selected. My question: How can I make the macro take two values into account at the same time, so 1010 AND 1020 in one go? I tried changing the list used in the drop down list but that does not work. Or is it impossible as the plant has been restricted to only one value?

View 5 Replies View Related

Variable To Store Multiple Values

Aug 20, 2009

I need a bit of help with the below macro which I am trying to create. I recorded the below vlookup, which works perfectly. It checks a list on sheet “Map” and returns a value depending on whether the reference is one of the 6 or not. These 6 are likely to change over time so I would prefer to declare them as variables rather than build them directly into the macro

View 4 Replies View Related

Determining Variable On The Basis Of Given Values

Feb 18, 2010

I'm working on this sheet and I can't figure out how to do it.

I'm trying to determine the variable "selling price" on the basis of given values, buying price, Net profit and Expenses.

View 4 Replies View Related

Keep Variable Values AFTER Procedure Ends

Mar 19, 2007

I have a User Form with 2 groups of 3 radio buttons let's say. The user must choose one button from each group, then press "GO" which runs specific code depending on what buttons they pressed.

How do I make the variables public or static so that after both radio buttons were selected, another seperate procedure in the same module (The GO procedure) can know what selections were made so it can run code based on those selections? In this example, there are only 2 groups of three radio buttons, but in reality I have 30 buttons and it keeps growing so I need the most direct/simple way to solve this.

For Example:

UserForm1
Radio Button Group 1:

Button 1
Button 2
Button 3

Same UserForm1
but now here is Radio Button Group 2:

Button 4
Button 5
Button 6

I need to know which buttons the user clicked from Group 1 and Group 2 after they finished both their selections from each group, and then run code depending on what combination of buttons have been selected. I'm good to go with the If/Then code to decide which code to run, I just cant keep the variables from reading as 'Empty' when I try to see what the user selected when pressing GO and running that procedure.

View 9 Replies View Related

Show Values Of Variable In Rows

May 16, 2007

I have a list of part numbers in a column and a list of suppliers in another column. Parts may have anywhere from 1 to 15 suppliers.

Is there an easy way to show each part number once down one column, with the suppliers going across the one row for each part number?

Example:
PN#Supplier
123ABC
123DEF
123GHI
123JKL
123MNO
123PQR
456ABC
456DEF
456GHI
456JKL
456MNO
456PQR
456STU

Desired Output:

PN#Sup1Sup2Sup3Sup4Sup5Sup6Sup7
123ABCDEFGHIJKLMNOPQR
456ABCDEFGHIJKLMNOPQRSTU

I tried a pivot table,

View 4 Replies View Related

Pass Variable Values Between Workbooks

Nov 20, 2007

I'm just starting to experiment with passing values between workbooks and between modules and so far I've managed to get it working. However, I now can not run the receiving module independently because of the passed value ? Let me explain ...

I use start/end dates within my modules to create date sensitive reports. I have several files (for different departments) and each file has a module called "AbsenceChecker", I have been working on a way to create a Report Master workbook to run and amalgamate the "AbsenceChecker" module from each department.

Sub RunAllLoaders()
Dim AbsenceStart As Date, AbsenceEnd As Date
Dim PassVar1 As Date, PassVar2 As Date
Dim DateStart As Date, DateEnd As Date
On Error Resume Next
'start of data validation script continued in private sub.
GetValidDates FromDate:=PassVar1, _
ToDate:=PassVar2, _
MinDate:=DateSerial(2007, 1, 1), _
MaxDate:=DateSerial(2007, 12, 31)
Excel.Application.EnableEvents = False
Workbooks.Open Filename:="R:RostersRosterALPHA.xls"
Application.Run "RosterALPHA.xls!AbsenceChecker", PassVar1, PassVar2
End Sub...................

View 2 Replies View Related

Excel 2003 :: Counting Values Within A Variable?

Mar 21, 2014

I am trying to implement a count on a table that splits up the number of customers associated with a list of managers. Sample data attached.

Count function.xlsx

So, I need some way to display a single instance of each manager name with a count of how many customers are associated with that manager. The number of managers and the number of customers associated with each manager does vary and are displayed in separate columns per the attached.

View 14 Replies View Related

Formula Only Look At Last 3 Values In The Column? (variable Rows)

Nov 14, 2008

For example I have a data set that will grow over time say 13 rows, I want to write a formula that will only use the last 3 rows with data entered and get the Median of those rows. I know that the Median Formula for the entire 13 rows would be =MEDIAN(A3:A16). Anyone know a way to make a Median formula only look at the last 3 in any given time without manually updating the formula's range?

View 3 Replies View Related

Define A Cell Range From Variable Values?

Jul 21, 2009

I have a range staring with cell "A5" and going to Column "K8+" that I need to copy. My issue is that the number of rows to copy will change. I have the number stored a variable "a" in my coding. how do I code this to work?

View 5 Replies View Related

Counting Unique Values Based On A Variable

Dec 15, 2009

I'm having difficulty trying to write a formula for the following type of data:

[data] ....

This is a data set with 10k+ lines; I have about 150 different items in the "Criteria" column. What I want to do is count how many unique items occur in "Column to be counted" by each vairable in the "Criteria" column. The output should look like this: ...

View 9 Replies View Related

Recognize Text Values As Variable Names

Jul 1, 2006

I want VBA to take an equation that has been entered into an worksheet cell as text and evaluate it. Here's a very simplified example that shows the concept:

Cell A1 may contain the text: "A * B + C"

I would like to do something on the order of this in VBA:

Sub Test()
Dim A As Integer, B As Integer, C As Integer

A = 2
B = 4
C = 6

MsgBox Evaluate(Workbooks("Book1").Sheets("Sheet1").Range("A1").Value)

End Sub

Obviously, this doesn't work, but I want it to show a result of 14. The actual situation is much more complex, but it all comes down to being able to evaluate the text in a worksheet and recognize the variable names that are in it.

View 7 Replies View Related

Assign Multiple Cell's Values To A Variable

Jul 23, 2006

Need exact VBA code syntax to assign a workbook (to be closed) sheet's cells J4 to J72 values to a variable called "ColJValues" to be assigned to another sheet (to be opened later in the macro). The values are all dates. Once the other workbook is opened later in the macro, need the exact syntax to assign the value in the above variable, "ColJValues", to it's cells J4 to J72.

View 8 Replies View Related

Assigning Variable Values To Letters In A Table

Jul 20, 2007

I have a formula which assigns a points score to letters in a range and adds them up. In the example below F=0, P=6, M=12 & D=18. =IF( COUNTIF(AT5:BE5,"="""),"",SUM(COUNTIF(AT5:BE5,"=F")*0,COUNTIF(AT5:BE5,"=P")*6,COUNTIF(AT5:BE5,"=M")*12,COUNTIF(AT5:BE5,"=D")*18)). Thus if F, P, M & D were in cells A1:D1 the result would be 0+6+12+18=36.

My aim is to be able to customise the values of F, P, M & D, using a table and a cell value. See the table below, where the first number in each row represents a cell value which the user enters into BH1, the second, third, fourth and fifth numbers represents the values assigned to the letters F, P, M & D.


10 0 1 2 3
30 0 3 6 9
60 0 6 12 18
90 0 9 18 27
120 0 12 24 36

Some examples of expected output: user enters 10 into BH1 and then enters F, P, M & D in cells A1:D1 the result would be 0+1+2+3=6. user enters 90 into BH1 and then enters F, P, M & D in cells A1:D1 the result would be 0+9+18+27=54.

View 4 Replies View Related

Calculation Error After Passing Values To Variable

Jan 30, 2008

I currently have a userform which inputs data into two cells, the third then multiplies these two cells together, which is all honky dory. It works, 2 x 2 = 4.
But when i put 0.6 for example it really doesnt work. 0.6 x 25 = 25. WRONG. My code in the macro is fairly long winded but will paste anyway.

If ComboBox2.Text = "Pounds (£)" Then
Sheets("Claims").Range("G16") = TextBox2.Text
Else
Sheets("Claims").Range("F16") = TextBox2.Text
End If

Sheets("Claims").Range("B16") = ComboBox1.Text
Sheets("Claims").Range("C16") = TextBox1.Text
Sheets("Claims").Range("B16") = TextBox3.Text
Sheets("Claims").Range("D16") = TextBox4.Text
Sheets("Claims").Range("E16") = TextBox5.Text

Dim a As Long
Dim b As Long
Dim answer As Long
a = Sheets("Claims").[E16]
b = Sheets("Claims").[F16]
answer = (a * b)
Sheets("Claims").[G16] = answer

View 3 Replies View Related

Store Range Values In Variable Array

Apr 20, 2008

I have a list of names from cell A1:A10 in sheet "Input." Each of these names has its own corresponding sheet in the workbook. I want to be able to run the same exact VBA code for each sheet. In other words, I am trying to get my name variable to automatically change to the next value on sheet "Input." I'm sure this is pretty simple to do, but I can't seem to find anything that works!

View 5 Replies View Related

Sum Values If Multiple Variable Criteria Are True

May 13, 2008

I'm trying to find the sum of a range of values based on multiple criteria, and the criteria is that the fields all have to be identical, then sum them. I've attached a brief example spreadsheet that has the fields

A=City
B=State
C=Values

What I want the formula to do is first find the range of all the matching states, then find the range of all the matching Cities within the states, and then sum the values based on them having matching city values.

I've been able to do that with one criteria using SumIf, I'm not sure if this will help paint an image of what I want to do:

=ROUND(SUMIF($B$3:$B$11,$B$3:$B$11,$C$3:$C$11),0)

But I can't figure out the way to do multiple criteria against itself. Most of the results I get from Google using multiple criteria are using a set few values, and I can't seem to figure out how to alter those methods to work with my situation.

View 9 Replies View Related

Calculating Adjusted Factor Based On Variable Values

Feb 7, 2014

Here is a table with values from Factor1 to Factor 5. Underneath that, for a specific index, I can mark Y or N for factor values. For instance, for index 1, Factor1 and 2 is marked as Y. The goal is to calculate total factor based on variable and factor values. In this case, variable value is 6, factor 1 =1 and factor 2=1.25). So Total factor = 6*1.25*1.5 = 11.25. If all factor values are marked as N, then total factor = variable value (Example is for Index 3)

How this can be implemented. I tried using COUNT function to count the total number of Y but that works only if all factors have same values.

Table_factors.jpg

View 4 Replies View Related

Multiple Cell Values Into A Variable - Then Place In Another Range?

May 17, 2014

how to set a cells value into a variable, using .value, then set another cells value equal to that variable without using copy/paste

What I can't figure out is how to see the value of multiple cells to a variable and place them into another range of the same size using .value. It would be nice to free up the clipboard.

View 2 Replies View Related

Store Value In Variable After Concatenation Of Two Values And Putting Into Same Cell

Dec 16, 2011

How to store a value in variable after concatenation of two values and putting it into the same cell.

Let assume, in cell A1, we have value 1 (numeric). And in code i have a variable with stored value as "%".

Now i want to concatenate 1 and % and put it back into cell A1 as 1%.

I have a written a code, but seems to be wrong one.

Sub Percentage()
Per = "%"
lr = Sheets("Process Overview").Cells(Rows.Count, 3).End(xlUp).Row
For i = 10 To Sheets("Process Overview").Cells(Rows.Count, 3).End(xlUp).Row
If Cells(i, 4).Value = "p" Then

[Code] ........

View 3 Replies View Related

Setting Values In A Variable Range Occurence Query

Jul 18, 2006

I am trying to count the occurences of combinations within a range defined by contiguous cell values in one column. My problem lies with setting the value of variables that are queried within the defined range. My macro should;

1)Set ComboValue1 & ComboValue2 values to A1 & B1 cells values respectively
2)define range to be searched by how many contiguous values there are in column D
3)search column E for 2 figure combination (defined by A1 & B1). If present increment counter by 1 and add to column C (to be visible in worksheet). If no match carry on
4)define new range by next set of contiguous values in column C
5) step 3
6)when all possible contiguous ranges defined and searched from column c, perform again on next combination down columns A & B with refreshed occurence counter
7)finish when all combinations are searched for

Sub CountComboOccurence()
Dim ListCounter As String
Dim ProgCounter As String
Dim Counter As Integer
Dim ComboValue1 As String
Dim ComboValue2 As String
Dim Rng As Range
Application. ScreenUpdating = False
ListCounter = 0
ProgCounter = 0
Counter = 0
ComboValue1 = 0.......................

View 2 Replies View Related

Countif Function For Counting Values Based On More Then 1 Variable

May 7, 2007

I'm trying to make a spreadsheet that will count the number of times a certain incident occurs, for a particular person, for a particular month. The attached spreadsheet is an example of what I need done.

For the attached spreadsheet, I need to find out how many times x employee has been late for x month, and how many times they've been late overall.

You can see one of the many tries I've attempted in the second sheet, but it doesn't seem to want to work. I have to be able to do this without VBA, because of signature issues.

View 9 Replies View Related

Performing A Specific Function Repeatedly But With Variable Values Each Time?

May 13, 2014

The spreadsheet has over 200K rows and two dozen columns. My job is to:

1. There are two columns, one is called OCR code where we have repeating ID's and other column is called Minutes Count which is basically a number. I have to filter the OCR column for similar OCR codes(values) and then add their time(Minute Count) so that I get total minutes for a specific OCR code. After adding the min I will copy them into a new sheet with the code in one column, total minutes in another and number of repeatitions for that specific OCR code or count number in a separate column. Example:

OCR_Code; Minutes
54xg; 456
45fk; 65
23IS; 18
54xg; 971
45fk; 265
.
.
.

Now I've to filter 54xg so that I can only see it and its corresponding minutes. Then I will add up all min for 54xg. Then I will count the number of instances a 54xg has been repeated in spreadsheet(here its 2 but it can be in hundreds in my case). Last thing is to transfer all this data to a new sheet. And automatically repeat the process for other OCR codes like 45fk, 23IS etc...

View 3 Replies View Related

Macro To Extract Variable Info From Data Set And Calculate Corresponding Values

Nov 16, 2009

I have a small data set (ends up with 8 columns, up to 1000 rows), that gets imported sorted and formated via a macro linked to a button. I need to be able to look at one particular column of info, which will contain different text values every time the data is updated, and create a list of all the different values that occur in that column (maybe 10 max). Then...... I need to calculate a numerical value from adjascent column, linked to the text values from the first process. Below is an example to better explain:............

View 2 Replies View Related

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

View 9 Replies View Related

Conditional Summing: Find Those Combinations Of Variable Values Which Generate Highest Total Gain

Jun 17, 2008

The aim is to find those combinations of variable values which generate highest total gain. I attached the spreadsheet which shows the variables (A through K) and a Gain column. I created 5 additional tabs which show all possible 2,3,4 and 5-member combinations of the variables. These tabs are like coordinates of which variable combinations should be examined. As an example I used the first combination from the second tab = A and B. If you look at these two columns on the EXAMPLE CALCULATION tab you will see 7,7 in the Number combination which is the first number pair for these two variables. The headings of the red and the yellow columns calculate the total count for this number pair and the total gain. These were recorded on a separate EXAMPLE RESULTS tab along with some other pairs which appear afterwards (these were recorded only from the first 39 rows of the AB data). I need a macro which will cycle through each variable pair (only using the combinations from the tab 2 for now, annd later from 3,4 and 5 tabs) collecting statistics for each unique number combination it encounters (printing to a separate sheet one after one), such as shown on the EXAMPLE RESULTS.

View 9 Replies View Related

Set Variable: Object Variable Or With Block Variable Not Set

Jun 4, 2007

I have the following code (just pasting the relevant section) which crashes when it reaches the highlighted line of code. and a dialog box pops up with the text: "Object variable or With block variable not set"

Sub test()
Dim StartRng As Range
Dim Buffer As Range

Set StartRng = WorkSheets("Sheet1"),Cells(1,1)

StartRng.Activate
ActiveCell. CurrentRegion.Select

Buffer = rngStart.CurrentRegion.Copy

' I also tried the following line of code but that didn't work either
'Set Buffer = rngStart.CurrentRegion.Copy
..
...
End Sub

View 9 Replies View Related

Multiple Options Cell Values Based On Multiple Criteria Variable Inputs?

Mar 18, 2013

I maintain the data flow at my work. We send and receive the data using excel files with specific formatting that I then upload to the database. Each time I send or receive the excel file I must log them, this is what my code question refers to.

I use RDBMerge to merge all the contents of the 100 plus excel files into one worksheet. The first part of the macro cleans up the merge data for use in the log (i have attached an example of the clean data and finished log).

The blue shaded area of the "Raw_Data" is what the clean data looks like, the yellow column is what current macro records for each record.

As you can see by the example the Raw_Data is only two files LL_LLL_BOB_ToLLLLL_20121228_01 & LL_LLL_BOB_ToLLLLL_20121230_01, each with more that one record.

The log code in column "H" Is based on this criteria:
First Letter of the Unique ID in column "E" - O, M, or L
Program Type in Column "F" - U or R
1. O-U = U
2. O-R = RU
3. M-U = U2
4. M-R = R2U
5. L-R = R

You will note that Columns G-R of the "Log Sheet" correspond to the "Record Type" found in Column "G" of the "Raw_Data" sheet.

This is the area where my skill at using scripting dictionaries fails.

The results for the log list each file only once, but the log code for each corresponding "Record Type" in columns G-R of the "Log Sheet" must contain each unique instance of the code. In other words

if LL_LLL_BOB_ToLLLLL_20121228_01 contains an O-U with an "A" Record Type and an M-R with an "A" Record Type; then, on the log sheet there needs to be the codes "U/R2U" in the cell intersection of the LL_LLL_BOB_ToLLLLL_20121228_01 record row and "A" column (which is column "G")

So, If the File contains one of each code for each Record Type the corresponding cell must house one of each code separated by a "/" without any spaces. This means the cell value could no code, or one code and all the variations in between to all five codes. Also, for ease of human reading the log codes should be concatenated in the 1-5 order that I listed them in (U/RU/U2/R2U/R)

Here is my code so far.

VB:
Option Explicit
Sub test()
Dim dic As Object, a, i As Long, rng As Range, e, w, n As Long
Set dic = CreateObject("Scripting.Dictionary")

[Code].....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved