Total A Column With Unknown Number Of Rows

Jan 24, 2007

In the code below, a formula is placed in column F to compute the total of that column. I first find the number of rows and place the formula in the cell below it. I'm dividing the sum by 2 since there are subtotals in the column.

Sub AddColumn()
Dim NumRows As Long
NumRows = Range("A65536").End(xlUp).Row 'get the row count
NumRows = NumRows + 1
Worksheets("Report").Cells(NumRows, "F").Value = "=SUM(F9:F308) / 2"
End Sub

The problem with the code is that I don't really know that the last row in the column is F308. I need to replace that part with a variable. It will be something like this (which I know is incorrect):

Worksheets("Report").Cells(NumRows, "F").Value = "=SUM(F9:NumRows) / 2"

How would I use a variable in the SUM function in place of the cell names? Should I even be placing the formula in a cell, or should I compute the sum in the macro and place the value in the cell?

View 2 Replies


ADVERTISEMENT

Formula To Total Column With Random Number Of Rows

Apr 6, 2009

I am copying various rows from one spreadsheet to another (sheet3) and would like to total one of the columns. The trouble is that since I don't know how many rows there will be I am having trouble inserting a formula that will work. I am sure that there must be a simple solution but I can't seem to find it.

View 2 Replies View Related

SUMPRODUCT Use But With Unknown Number Of Rows?

Sep 15, 2012

I need to put a value on every line having "file:" in the second column. The value requested is a sum of the numbers in the forth column following this line until the next "file:" line.

I know it is not trivial, but sure it is possible.

57
file:
HIRES-~1
#VALUE!

58
208
1
1

[Code] ...........

View 9 Replies View Related

Sort Unknown Number Of Rows

Sep 30, 2009

I am working with 2 workbooks the first one "LH Enrollment" is used to enter information for new students being enrolled in the program. After the information is entered the macro is then copying the information to the second workbook "LH Children Records". The part I'm stuck on is that I now need to sort alphabetically by last name which is entered on Sheet 1, Column B of "LH Children Records". The number of columns will stay the same but the number of rows will change each time a new child is added. Eventually all this information gets copied over to several other workbooks, but I'm stuck trying to sort. I have attached both workbooks

View 5 Replies View Related

Combining Worksheets With Unknown Number Of Rows

Dec 16, 2009

I am trying to find a way to combine two worksheets with identical columns and an unknown number of rows. Both sheets use columns A through K.

I want to add a new sheet called "Combined orders", then copy data and headers from Sheet1, paste it to Combined orders, copy data only from Sheet2, and paste it on the row after the last row of data from Sheet1.

Sounds easy but I am easily confused by the unknown number of rows in each data set. Can someone please help?

Also, are there a few lines of code that I can copy and paste into new macros that will make the unknown rows problem easier for me in the future? (i.e., instead of just showing me the code, can you also please explain the concept behind it so I can learn for future reference?)

View 7 Replies View Related

Fill Conditional Cell Values Based On Unknown Number Of Rows

Dec 15, 2009

I have a set of data in column R, with an unknown number of rows that looks like this

Days Late
-28
150
3
16
41
.
.
.

and I have written a script to add an adjacent column "S". I want to fill column S with conditional values based on the value of column R, sorted into categories such as "On Time", "Less than One Month Late", etc. Here is what I have so far, it doesn't work:

View 4 Replies View Related

Find Text String And Report Back Data In Unknown Number Of Rows

Apr 26, 2007

For example

Name Address Phone # zip
Danielle 4561
Danielle 9852
Danielle 22
Danielle 69
Joe 895
Joe 28
John 9821
John 1114
John 698

Say I did a search for Joe. I want to report back all the addresses in which he resided but there's no way to tell how many rows of data each person has. Joe has 2 rows, Danielle has 4 rows and John has three. How do I report back all the relevant rows?

View 11 Replies View Related

VBA - Copying And Pasting Unknown Number Of Values Each Different Number Of Times

May 28, 2014

I am trying to come up with a macro that selects values from one sheet and inserts them into another sheet. The number of values will change each time based on the user's entry, as well as the number of times that each entry should be pasted.

For example:

Entry: X | Y | Z
Number of Times to be Inserted to New Sheet 3 | 2 | 1

Result:
X X X Y Y Z

I have spent a while trying to figure it out, however the best I can come up with is using an array, but I can only get one value from the array to paste multiple times:

(*Note: In my testing, I didn't insert into new sheet or set up the array to handle different values, I was just trying to get the basic idea to work)

Dim A(1, 3) As Variant
A(1, 1) = Range("C3").Value
A(1, 2) = Range("D3").Value
A(1, 3) = Range("E3").Value

[Code].....

View 3 Replies View Related

To Find A Total Number Of Rows To A Blank Cell

Mar 14, 2007

I need to find the total number of rows down to the next blank cell (and then perform a function based on that number).

I'm using:

CountA(A1,xlDown)
Situation: I have a raw data import - each record is anywhere from 2 to 9 rows, and I need to move each row in that group into a column.

I would like to use something like:

totalRows = Application.WorksheetFunctions.CountA(Range("A1, xlDown"))
If totalRows = 4 Then
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.Cut
ActiveCell.Offset(-1, 1).Range("A1").Select
ActiveSheet.Paste
etc.

View 9 Replies View Related

Delete Rows Until, Total Found In Column

Jun 24, 2009

Is there a macro that will begin in cell A2 and delete rows until the contents “Total” is found in a random row in Column A?

View 4 Replies View Related

Sum Across Unknown Number Of Worksheets

Sep 20, 2007

The colours are just to mark the ranges

As every month is different the number of sheets adding up to the Red sheets(week total)
will change and the same with the Blue sheet(month end total)

Is there a code I can run for this summing up to be done?

Yellow is where data is entered

Red is where the Yellows range sheets need to add up before it

The Blue is where all the Red range sheets need to add up

View 9 Replies View Related

Balance Column Total Repeats In Empty Rows

Dec 27, 2011

My balance column is formulated for 60 rows. I am currently on row 23. The balance is repeated down the entire sheet range I have set. How do I keep the balance from showing next to an empty row without losing the formula?

View 1 Replies View Related

Summing Across Unknown Range In Unknown Cell

Oct 26, 2009

I've been working on a spreadsheet and these forums have been a great help. I'm now at the very last section and, surprise surprise, it's also the hardest!

I'm creating a stock trade recording sheet. I have a userform ask the user to enter a date, a time, the number of stock purchased, and the price of the stock. These are then entered in a new row.

Now what I want to do is have summary cells which say how many stocks were purchased and the total profit made for each day. Since each time is given its own row, I can't know in advance which rows to sum over. I also don't know on which days a trade was made. So a summary cell should only exist if a trade was made that day.

Could I do something like.... check if the date matches then sum over all the values for that date? So if column A has the dates, can I say "Search which rows in column A have this date" then "for those rows, sum column C"?

Also, how would I create a a row for each traded date's summary cell and enter the date in it? I've attached a spreadsheets which manually demonstrates what I want to do (no macros) and a spreadsheet with what I have so far (basic macros).

Any and all help much appreciated, I just need to get my head around creating and dealing with variable ranges. Is that a really advanced task? I don't think this is a one line solution so please bear with me while I make mistakes!

View 14 Replies View Related

Combining An Unknown Number Of Cells Into One

Nov 4, 2009

I have the following setup,

Down column A I have a list of jobs, job 1 , job 2 etc
Down column b I have either a blank cell or other data (will be numbers but is irrelevant)
What I want is a formula for a cell that tells me which titles in column A have any data at all in column b. I need it to look like the following : Job 1, Job 2, Job 4
assuming b1 b2 and b4 have any contents and b3 and b5 and onwards are empty

I am seeing that concentate gives me close to what I want but the number of rows in column a and b change constantly and also may be above 30

View 9 Replies View Related

Accounting For Unknown Number Of Worksheets

Jun 28, 2006

I have a macro set up to copy and paste data from worksheets into worksheet 1. But the number of worksheets often changes. Is there a way to write this to include all worksheets even if the number changes?

Windows("0285 WORKING FILE 0406.XLS").Activate
Sheets(3).Select
Application.Goto Reference:="R500C33"
Range("A9:AG500").Select
Range("AG500").Activate
Selection.Copy
Sheets(1).Select
Application.Goto Reference:="R501C1"
ActiveSheet.Paste
Sheets(2).Select
Application.Goto Reference:="R500C33"
Range("A9:AG500").Select
Range("AG500").Activate
Application.CutCopyMode = False
Selection.Copy
Sheets(1).Select
Application.Goto Reference:="R1001C1"
ActiveSheet.Paste

Sometimes I will receive this file and there will be additional tabs. I just never know how many.

I copy down 500 rows knowing there will never be more data than that. And for each worksheet I paste to sheet 1 I add 500 rows to not paste over other data.

I would like the computer to read it as "select last indexed worksheet, copy paste to index 1, repeat while selecting the left adjacent worksheet until you reach index 1.

For each new worksheet selected add 500 rows to the last pasted amount."

View 7 Replies View Related

Average Unknown Number Of Columns

May 25, 2008

I am trying to average a range which continually changes depending on the amount of registries entered in a given week. for example, one week there may be 5 registries which would fill five columns while another week there may be 15 registries, once again filling 15 columns. I would like to find the average of x amount of columns.
My initial approach was to select the first blank cell to the right of the data and then find the last filled cell (which should be the first column of data.
with this range i tried hopelessly to use the average function (did not work):

Sub averagemake()
Dim iLastColumn As Integer
Dim Rng As Range
Sheets("All Data(Values)").Select
Range("A6").Select
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
iLastColumn = Cells(6, Columns.Count).End(xlToLeft).Column
ActiveCell.FormulaR1C1 = "=AVERAGE(RC[-iLastColumn]:RC[-1])"
End Sub

View 5 Replies View Related

Sum To Unknown Rows With Conditions

Apr 24, 2006

Need to sum through an unknown number of row generated by advanced filter at run-time

Formula at C16
Data starts at row 57 (from copy/paste - advance filter)
Last row unknown

Criteria to match in A16
Data to be evaluated in B57:B (row unknown)

Found this formula on microsoft.public.excel.misc
=SUM(A57:INDEX(A:A,MATCH(9.99999999999999E+307,A:A)))
Which I modified formy start row

View 9 Replies View Related

Excel 2013 :: Formula For Getting Job Code To Appear In Column A Of Total Rows

Mar 10, 2014

I've got general ledger information that I export out of my accounting software (see attached spreadsheet). From there, in another spreadsheet I do vlookup formulas to get information from this general ledger. However, in order for the vlookup formulas to work properly in the other spreadsheets, I have to go through this general ledger spreadsheet and manually enter just the first five numerical digits in column A for each Total row. I would like to be able to find a solution that would return just the first five characters of the category (column B found at the top of each section) into the cell in column A on each total row. I usually have to manually enter 50-100 of these many, many times a month so it gets time consuming after a while. I'm using Excel 2013.

View 1 Replies View Related

Running Total Based On Content From Column For Over 1700 Rows?

Mar 26, 2014

Currently have a sheet with column A/B. Column A has any of the following letters to represent Wins, Losses, Ties, Overtime Loss, Shootout Loss - W, L, T, OTL, SOL. Column B has team point totals after each result. So after the win in row one, the team has 2 points. After the losses in rows 2 and 3, the team still has 2 points. After win in row 4 the team has 4 points. After win in row 5 the team has 6 points. After tie in row 6 team has 7 points.

W
2

L
2

L
2

W
4

W
6

T
7

What is the best formula or is there a formula to easily calculate running total based on content from column A this for over 1700 rows?

View 9 Replies View Related

VBA Join Function For Unknown Number Of Arguments

Feb 13, 2012

have a function that takes an unknown number of ranges (worksheet cells) as arguments that can then be joined with the provided delimiter.

It should ignore null values.

I saw that someone posted the following line of code:
Replace(WorksheetFunction.Trim(Join(myArray)), " ", ",")

So I guess my real question is how to pass an unknown number of arguments into a function and put the values in an array.

View 3 Replies View Related

VBA Copying Unknown Amount Of Rows

Jul 15, 2009

I need to know the function to copy an unknown amount of rows. After a certain row it should copy everything.

So like after row A6 it copys every row below it with data in them then I want to paste it in another worksheet. I dont want to just do

Rows("6:65000").Select
Selection.Copy

If someone could point me to a good site that explains alot of useful VBA commands that would help me alot. Most of my problems come from just not knowing the full function names.

View 10 Replies View Related

Add Data From Unknown Number Of Sheets To Summary Sheet

Aug 1, 2008

How to I add data to an existing summary sheet, in a specific cells, from an unknown number of sheets?

Tickets will be generated with unknown names.

I want the summary sheet to be able pull the ticket numbers into the top row of the summary sheet, to an undefined number of sheets.

As well I would like the summary sheet to pull the job# on each ticket and the hours for each person on each ticket.

View 5 Replies View Related

Range Of Cells Of Known Columns But Unknown Rows

Mar 19, 2008

I'm working to build a macro to help clean up data I download out of our company's online resources. I know that the data will run from column A to N but the number of items (and thus number of rows)will change. I need to sort all used rows except for the last one (which containes totals and I don't want to include in my sort). So right now I'm just trying to figure out how to select from A3:NX, where x is the row above the last used row.

What I've managed to find so far on the forums is

Offset("$A$3", 0, 0, (Match(9.99999999999999E+307, "N:N", 1) - 1), 14).Select

which I think should find the last row in N to have a number in it, minus 1. However I'm getting a compile error that function or sub are not defined. (seemingly refering to the Match, but I'm not sure).

View 6 Replies View Related

Macro Allow To Total The Data On The Total Sheet Depending On What Unit Number Is Selected

Apr 22, 2009

This may not be the best way to do this, but I don't know Macros or Pivot Tables.

I am looking for a way with formulas to do the following:
Within a workbook the 1st sheet is the data entry.
In another sheet that will total data from the data sheet is where I want to be able to total columns of data, depending on what is entered in one specific column:

Example:
Data Sheet, E2:E2999 is a unit number selcted by pull down tab entry.
G2:G2999 in the same sheet is where the data is.

Q: What formula would allow to total the data on the Total Sheet depending on what unit number is selected in column E on the Data Sheet and the data amount in column D from Data Sheet?

View 9 Replies View Related

Add Each Day's Total While Displaying A Positive Number If The Total Exceeds 6000

Dec 21, 2008

I'm sure this can be done but I don't think I have the formula correct. What I am trying to do is add each day's total while displaying a positive number if the total exceeds 6000.

View 5 Replies View Related

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.

View 9 Replies View Related

Formula To Multiply Total Number Per Category With The % Of Total?

Dec 13, 2013

number for item detail level from category standpoint. For example, in the category sheet has total number per category and per month and in the item detail sheet has a list of item number with category. I want a formula to recognize which item belongs to which category then use the total number of category by month to multiply with % of total in column D from Item Detail Spreadsheet.

View 2 Replies View Related

Macro: Create Named Ranges. Unknown Columns/Rows

Sep 9, 2006

I need to make named ranges from an unknown number of columns(at least 1) each with an unknown number of rows. Each column has the name of the named range as the first row, and then a variable number of rows containing part numbers.

I can do it 1 by 1, but id rather do it in a loop so that blanks dont cause errors. there will be different people using versions of this sheet with different model/part number information What i've tried: Count number of colums with row 1 containing data (11 max, which is more than will ever be used) add into array(I know i dont really need to add into the array, but i might use it later for some other code). The problem i'm having is finding the range of rows that need added to the named dynamic range and adding it.

modelcount = Range("G7") 'G7 (for now) contains =COUNTA(H1,I1,J1,etc)

For i = 1 To modelcount
Redim Preserve Models(0 To i)
Models(i) = Cells(1, i + 7)
Range1 = Cells(2, i + 7).Address(xlA1)
lastRow = Cells(rows.Count, i + 7).End(xlUp).Row
Range2 = Cells(lastRow, i + 7).Address(xlA1)
Reference = Cells(2, i + 7).Address(xlA1)
ThisWorkbook.Names.Add Name:=Models(i), _
RefersTo:="=OFFSET(Reference,0,0,counta(Range1:Range2),1)", Visible:=True
Next i

This gets me the range i need, but doesnt create the named range properly. If i go to insert>names>define, the named ranges are created, but they dont relate to the data in any columns. It shows the variable names rather than the cell range the variable represents.

View 2 Replies View Related

Select Column Of Unknown Length Using VBA

Jul 14, 2014

I have a column that begins in the same place all of the time (Cell C6) however the length of this column can vary. How can I copy the column using VBA?

View 2 Replies View Related

Set Variable To Unknown Last Used Cell In Known Column

Jun 24, 2008

I'm trying to define the last row in a column which is determined from a find command. It's quite a large sub, and the rest is working properly, so I'll just post the (still rather large) troubling section.

'startingPoint is declared as a range. Destbook, reporttarget and FullControlName all exist.

'this sets StartingPoint to a one cell range in a sheet named from a custom class in a workbook named from variable destbook

Set StartingPoint = DestBook.Sheets(ReportTarget.Name).Cells.Find(what:=FullControlName, searchorder:=xlByColumns)

WriteCol = StartingPoint.Column

'this changes the range to include the whole column of the existing range
Set StartingPoint = Range(StartingPoint.EntireColumn.Address).....................

View 2 Replies View Related







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