Function To Sum Number Of Rows Based On Variable
Jun 23, 2014
As you can see in the attached excel doc, I have calculated a column for "Number of Claims Per week" and also "Dollar amount Per claim". This was done using VLOOKUP and distributions. That is not the issue.
The issue I am having is creating the "TOTAL" for the week. So for example, if week one generates 4 claims, I need to be able to add up claim amount #1-#4.
It seems as though this would be a basic function, but I can seem to find a way to add up a certain number of cells, based on a variable generated from a random number.
If you take a look a my excel sheet, I am trying to solve for the "Claim Total" column on the far right. This column should be the sum of (Number of claims * The individual amount per claim). Note that if there is 4 claims in that week, I would have to add up claim 1-4 to get that weeks total.
Question2.xlsx‎
View 9 Replies
ADVERTISEMENT
Aug 8, 2009
On the attached Excel file, I have code that will insert a variable number of rows and copy and paste from and to variable positions. That all works fine when run from a command button, but when I try to run it from the Worksheet_Calculate by entering 1 in J1 or K1 (inrange cell is J1+K1 for testing purposes) the CommandButton1_Click sub runs continously until an error occurs.
View 4 Replies
View Related
May 10, 2013
how to create a custom function with an unknown/changing number of input parameters?
Specifically, I need to create a function that will calculate the average of 1,2 or more ranges. I can't use the built-in average function as I then need to use the average in my function.
what I have so far is:
function points(current as range, previous as range)
if previous > current then final=1
if previous < current then final=0
if previous = current then final=2
points=final
end function
This works okay if I only only have 1 range of values. but in my worksheet I need to be able to enter =points(a1,c1:f1,g1) and have the function calculate the average of c1:f1,g1 and compare it to a1.
View 6 Replies
View Related
Aug 7, 2009
I reckon this should be easier than I'm finding it, but I just can't seem to find the right combination of functions to solve this. In column A I will have an entry every 5 or 6 or 7 rows with blanks rows between. In Column B starting at every row corresponding with an entry in Column A there will be a short column of figures could be 1 2 3 or four or more of them. (the're will always be a blank between the last number in a group in B before the next entry in A). In column C starting at every Row corresponding to an entry in column A I want the sum of the group of figures in Column B.
But here's the rub.... The most important thing is that I can use the same formula all the way down column C. So click the one formula at the top and drag it all the way down 1000 rows.
View 4 Replies
View Related
May 29, 2008
I am having to copy and paste rows of data into a new worksheet where the rows sizes change and I am wanting to add a new row at the end of the pasted rows but with the sumation formula to add the relevant column
e.g copy range B14:AA17 with in this case columns E to AA holding the numerical values. Therefore I wish in cell E18 to sum the value of E14:E17 and so on ending with cell AA18 holding the sum of AA14:AA17
As these vary I have all relevant variables, Range to add sumation values to eg E18:AA18
Start Cell E14 and so on.
I tried adding "=SUM(x:d)" where x and d are vars relating the the column cell required eg x = E14 and d = E17
View 3 Replies
View Related
Nov 2, 2011
I'm trying to write a macro with a variable number or rows depending on the total number of rows the workbook has.
I tried like this:
Code:
Sub provaanova()
Application.Run "ATPVBAEN.XLAM!Regress", ActiveSheet.Range(("$J$2:$J$") & Range("J" & Rows.Count).End(xlUp).Row) _
, ActiveSheet.Range(("$J$2:$J$") & Range("J" & Rows.Count).End(xlUp).Row), False, False, 99, "ANOVA", False, _
False, False, False, , False
Cells.Select
Cells.EntireColumn.AutoFit
Range("A1").Select
End Sub
and:
Code:
Sub Provaregress()
r = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
Application.Run "ATPVBAEN.XLAM!Regress", ActiveSheet.Range("$J$2:$J$r") _
, ActiveSheet.Range("$K$2:$M$r"), False, False, 99, "ANOVA", False, _
False, False, False, , False
Cells.Select
Cells.EntireColumn.AutoFit
Range("A1").Select
End Sub
But it gives me an error. The only way i was able to do it without error was:
Code:
Sub Provaregress()
Application.Run "ATPVBAEN.XLAM!Regress", ActiveSheet.Range("$J$2:$J$53968") _
, ActiveSheet.Range("$K$2:$M$53968"), False, False, 99, "ANOVA", False, _
False, False, False, , False
Cells.Select
Cells.EntireColumn.AutoFit
Range("A1").Select
End Sub
But as u can see it has a fixed number of rows. ( I need variable number of rows detected on column J, and then run regression with K,L,M as depending variables).
View 5 Replies
View Related
Nov 7, 2008
I have made a very basic spredsheet which using an assumption table makes a particular column of values which works out the revenue. Then I just drag the box down to the number of rows I want it to go down.
However, I want to be able to enter a number in a CELL away from the tale eg. 50 and have the number of rows in the column go down to 50
View 9 Replies
View Related
Aug 16, 2008
I'm trying to write a macro that will validate data in variable amount of rows but will always be in a specific column. what i'd like to do is count the amount of row entries in Column A to give me "iRows." Then validate data in column E from E1-E"iRows." Currently my data validation runs for the entire column which means i can not validate blank entries. Once I can limit the validation process from E1 to E "iRows" then I can consider blank fields and mark them as invalid.
Columns("E:E").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateDecimal, AlertStyle:=xlValidAlertStop, Operator _
:=xlGreater, Formula1:="1"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = "Award Amount"
.ErrorTitle = "Award Error"
.InputMessage = _
"Please enter the current expected total value or current award amount for this contract."
.ErrorMessage = _
"Award amount may not be set to 0.00. If you do not have an amount awarded simply make the award amount equal to the paid amount."
.ShowInput = True
.ShowError = True
End With
I've tried using different ways of counting the rows and have been able to define "iRows" the problem is defining the range to only column E from E1 to E"irows."
View 4 Replies
View Related
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
Oct 19, 2009
I need the variable here to be 7 numbers long, if not I need to add zero's at the beginning. However the problem I am having here is when then number of zero's is greater than one.
Basically in the example below the variable 'Zeros' = 2 so I need the variable 'Variable' to give answer "00", how do I do this!?
If Len(ActiveCell.Value) 7 Then
Zeros = 7 - Len(ActiveCell.Value)
Variable = CStr("0") * Zeros
End If
View 10 Replies
View Related
Jul 23, 2012
I have a sheet with a company name in column A, and a list of comma separated values in column B. I can easily convert column B to multiple columns with the Text to Columns function, but then I'd like to insert each individual value in a new row in column B.
So, at the moment I have data that looks like this:
Company A
Value 1, Value 2, Value 3, Value 4, Value 5
Company B
Company C
Value 1, Value 2, Value 3
[Code].....
View 6 Replies
View Related
Jan 13, 2009
I am working on a macro where I am creating a formula to string together some text columns and then copy the formula down the entire column. The data source I will be performing this on will change in number of rows period to period. The data would be in columns A,B & C and the formula is in D. The formula in D is stringing together the data in AB & C and then I want to copy and paste that formula down to the bottom of all of the data. What would the code be for the copy and paste with variable rows?
View 9 Replies
View Related
Jan 25, 2010
Inserting Variable Number Of Rows and Populating Data
View 10 Replies
View Related
Apr 24, 2014
I run a report that dumps from data from an ERP system. I've attached a sample of this report in excel that has two sheets. A summary and the data.
I am able to report on the total number of Purchase order lines and total purchase orders using various formulas. I am also able to use formulas to report on the number of lines associated with each product in the I column.
However I cannot, how to calculate the number of unique Po# (B Column) numbers based on the Product (I Column) .....
View 14 Replies
View Related
Dec 20, 2006
I have a bit of a curly one - I have a sheet with 9,000 records that I need to expand to 24,000 + on a separate sheet records using the following method:
1) Select and Copy entire row 2 from sheet(1)
2) Insert a number of new rows into sheet(2), based on the value of cells(2,8) or cell H2. Column H contains quantity values for each of the 9000 rows which are variable.
3) Repeat for row 3, copying and inserting into sheet(2) based on the value of the cell in H3.
4) loop through all records until complete
I have tried writing the code in VBA but am not even getting close!
View 9 Replies
View Related
Jun 16, 2014
calculate the number of full rows in one data base located on one sheet X to determine how many rows the macro needs to extend on sheet B (sheet B is made only of formulas for data interpretation in sheet A.
View 14 Replies
View Related
Sep 19, 2009
Here’s an example of my data:
A B
1110AAAAAAA
2220BBBBBBBB
3330CCCCCCCC
4330DDDDDDD
5330EEEEEEEEE
6440FFFFFFFFF
7440GGGGGGG
8550HHHHHHH
I need your help to figure out how to merge the above data to look like this in new blank worksheet using a VBA macro:
A B
1110AAAAAAA
2220BBBBBBBB
3330CCCCCCCC
DDDDDDD
EEEEEEEE
4440FFFFFFFFF
GGGGGGG
5550HHHHHHH
View 10 Replies
View Related
Jun 11, 2014
I have a spreadsheet which contains our fleet information covering many vehicles in one list. The teams for these vehicles are listed in Column A. What I would like to have is:
A dropdown box to pick from All, or the various teams in A1To hide every row that doesn't match the selection of A1To reveal every row that contains the selection for A1 at any point in column A. e.g: "*Dog Team*"
This is because something might be listed as "Moved from Dog Team" or "Dog Team, temporarily on loan", or "Dog Team V66.m"
I have taken a small sample of the data I will be working from and made a very simple drop down box which displays the pages of information for the vehicles by hiding/unhiding blocks of columns:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$2" Then
If Range("A2") = "MOT/Service" Then
ActiveSheet.Columns("A:P").EntireColumn.Hidden = False
ActiveSheet.Columns("Q:CE").EntireColumn.Hidden = True
ElseIf Range("A2") = "Contact Details" Then
[Code]....
But because there is also filters on the sheet, meaning the positions of the entries based on rows can change, I need it to search for the "*xyzzy*" method, but am unsure how to do this! While just using the Filters will work, due to some human limitations I have been asked to have a specific drop down box in a very specific location with instructions next to it.
View 1 Replies
View Related
Jun 17, 2014
I need an OFFSET function to start off by moving down 1 row from the starting point and then on the next run through the loop, to move down 2 rows, then 3 rows, etc.
Code:
Workbooks(Thisname).Worksheets("Run Set Up").Range("Duration").Offset(1, 0).Value = Workbooks(Filename2).Worksheets("Front Page").Range("T20").Value
This is what I'm working with. At the moment, I have the value for the number of rows to move set to 1 because I can't figure out how I'd accomplsih what I need.
View 1 Replies
View Related
Feb 27, 2014
I have two columns in a spreadsheet that I want to use an IF function with. In the first column, I want a pick list containing 5 text options. Depending on which option is chosen, I want a number to auto-populate in the second column.
The numbers are important, because I want to repeat this pair of cells with slightly different text values in the second pair, and then to have a column that multiplies the two resulting numbers and conditional formats the result.
View 14 Replies
View Related
Jul 26, 2012
I have wookbook with a lot of sheets on it
The first sheet to be filled is called "Local Info"
In this sheet in the Active Cell "G7" the user must register a number between 0-500
This number must affect my next sheet called Competence Map Autofilling rows 7+8 from Columns A to AM
So If for example I put 83 in "local INFO" G7.
I will get 172 rows with text (the first 6 Headers) the 7-8 original and from 9-172 filled with the information given.
View 3 Replies
View Related
Apr 25, 2014
I am trying to write a macro in VBA excel 2010 that compares 2 sheets.
The macro should be something along the lines of if column 7 on sheet 1 = column 1 on sheet 2
AND
on that same row if column 6 on sheet 1 = column 3 on sheet 2
highlight green
** also on sheet1 there can be the same batch ID so if it is the same batch ID it needs to calculate the sum and look at that amount...
Sheet1:
settleid
min Tran Date
Payment Vehicle
total Deposit
total CF
total MRI
RMBATCHID
475-T
03/03/2014
Connect
$562.95
$19.95
$543.00
6G000001450835
[Code] .......
Results >
Sheet1:
settleid
min Tran Date
Payment Vehicle
total Deposit
total CF
total MRI
RMBATCHID
475-T
03/03/2014
Connect
$562.95
$19.95
$543.00
6G000001450835
[Code] ..........
View 9 Replies
View Related
May 11, 2009
My worksheet has data in column A. A formula is placed in cell B2 (col headers are in the first row). What is the code to copy it down so it coincides with the rows in Column A? If I use the following:
View 6 Replies
View Related
Aug 14, 2007
I have a problem of having to repeatedly copy and paste a series of data based on the number of occurrences in each row of data series. For instance:
[Road Name] [Building Name] [No. of occurrence]
(1) [Scotts Rd] [Tangs Building] [38]
(2) [Orchard Rd] [ABC Building] [3]
(3) [French Rd] [DB Bank] [1]
I will need to duplicate (1) 38 times with the location name and building name. Similarly, I need to duplicate (2) 3 times. How can I simplify it programmatically?
View 3 Replies
View Related
Jan 31, 2008
I have a spreadsheet which contains data needing to be re-formatted into a suitable format for my database. So far I have been doing this by hand, but want to make it quicker as I have over 2000 lines to sort out. I am trying to write a macro that determines whether there is data in the column next to the active one (D2), and if there is counts how many columns there is data in. Once it has done this it needs to insert the same number of rows as there are columns, then copy the column data and transpose it into the empty rows. My macro seems to work at first, but it exits after around the 4th row, but I can't work out why.
Sub split_For_Database()
Dim No_Of_Cells As Integer
Dim Start_Cell As Range
Dim Cell As Range
Dim LastRow As Range
Dim i As Integer
Dim lRows As Long
Set LastRow = Range("C65536").End(xlUp)
i = 0
Set Start_Cell = Range("C2")
Set Cell = Start_Cell
Do While Start_Cell.Address <= LastRow.Address
Do While Cell.Offset(0, 1) > 0
i = i + 1
Set Cell = Cell.Offset(0, 1)
Loop...................................
View 8 Replies
View Related
Apr 23, 2014
I have an excel sheet that I've automated for my shop ... Basically it copies a set of rows from one sheet, asks for which cell you want to start the paste at, then pastes it... Here's what I have so far:
[Code] .....
So I tried to use a variation of strReturn to indicate number of rows wanted but that didn't work ... Basically I'm going to create the "data" to include 50 rows, but have it selectable for the user to say they only want 5, 7 or 29 rows ...
View 2 Replies
View Related
Jun 3, 2014
create a macro that will insert a certain number of blank rows to my spread sheet. The number of rows is determined by the #of tasks calculated for that day and is in column B. For example if in column A the date is 01-07-14 and in column B it has 7, I would like 7 rows inserted with the date in column A to remain the same in all 7 rows. Ideally I would like to use this macro for every row, so if the next row down has 02-07-14 and 6, I would like it to add 6 new rows with the same date.
I have attached a copy of the spread sheet for reference.
View 4 Replies
View Related
Feb 20, 2009
Column B contains geographical Areas. Column C contains a list of business departments.
North Env
North Env
North Ops
North Sales
North Sales
North Sales
South Env
South Maint
South Ops
South Sales
South Sales
South Sales
Etc.
The values and number of these departments will vary. I want to insert lines to sum the totals at the bottom of each geographic area based on the number of different departments. So, for this example, for the North three lines would be inserted. For the South, 4 lines would be inserted.
View 4 Replies
View Related
Jun 16, 2009
I have formulas in cells B8:F8. I need to copy these formulas down based on the number of rows in column A that has data. The data in column A will vary based on user input.
View 2 Replies
View Related
Nov 11, 2012
If only 1 row is selected, it works fine, but if I've selected multiple rows it continues forever. I want to create a row in my ListObject based on the number of selected rows.
Code:
Sub CreateRow()
Dim rRow As Range
With ActiveSheet.ListObjects(1).ListRows
For Each rRow In Selection.Rows
.Add (rRow.Row - 2)
Next rRow
End With
End Sub
View 1 Replies
View Related