Formula Or Macro To Sum Last 2 Numbers In Range?
Jul 12, 2013Every month in Column A I will add 2 numbers to my range. I want my formula or macro to sum the last two numbers in that column
View 1 RepliesEvery month in Column A I will add 2 numbers to my range. I want my formula or macro to sum the last two numbers in that column
View 1 RepliesHOW DO i WRITE A FORMULA FOR 0 TO 5000 = 2% 5001 TO 10000 = 1% and over 10000 = .5%
View 2 Replies View RelatedI'm making an eligibility chart based on income. If 1 person (equals a
household) makes between $0 and $1000 (household income) they are in "x"
category. if that person makes between $1001 and $2000, they are in "y"
category. If that person exceeds $2000, they are in "z" category. So I have
3 categories they can be included in (x=Free, y=reduced, z=paid...it isn't
just a true and false statement). The tricky part is the number of people in
the household. 2 to infinite # of people making in the range of $0-$1000
need to be in "free" category. 2 cells are being drawn from. A1 is the
number of people, A2 is the income, A3 is the formula for figuring their
eligibility. I need A3 to say "Free", or "Reduced", or "Paid" as the end
result of the data.
I'd like to take data in the range from B2:B500 and in C2 sum from B2:B9 and then in C3 sum from B10:B17 and in C4 sum from C18:C25 and so on.
View 2 Replies View RelatedI cannot find the right catagorty I need to use to word this. I know there is a formula out there. I basically have 1k numbers I need to add into Collumn A of a worksheet - the numbers are from range 34-2501 through 34-3500. How can I get excel or VBA to do this automatically?
34-2501
34-2502
34-2503
repeat til
34-3500
Also, how to make it user friendly to create the same process over and over with a different set of numbers... meaning make it so I onlt have to input the range or numbers over and over. if it is an easy task I do this allot
Is there a macro that get the average of the best 3 out of 5 in a range of numbers....if the range doesn't have 5 then adjust with what it has.
ex..
a....65 66 54 33 72
b....57 57 42 70
c....55 45 22 65 80
d....78 34
e....66 66 54 23 56
f....55 66 77
I would like a formula to add up values in Col E based on a range of account numbers in Col C
For eg adding up Sales values in Col E based on Account number being series 3000-3015 in Col C (this particular series must exclude numbers ending in an alpha). I also have account numbers ending in an Alpha where I need to add up the values pertaining to these for eg 3000D-3015D, 3000K-3015K etc.
I am trying to return several values >10K, >5K, >3K, >1K,
View 7 Replies View RelatedI came up with this formula trying to fix phone number but it’s not working properly
FORMULA:
=TEXT(LEFT(SUBSTITUTE(a1, "-", "") & "00##", 10), "###-###-00##")
So basically I need a formula or macro that will fix the phone number for me.
Here is an example
78512312 it should be like this 785-123-0012
Or
785123123 it should be like this 785-123-0123. So if Len is 8 numbers long then insert two zeros counting from right to left. So if Len is 9 numbers long then insert one zeros counting from right to left.
First my goal is to sum a row and column. For example i want the sum of row 1 a to row 1 g. However, I'm using a loop for an automated macro. So i want to be able to say something like cells(1, count), so during the loop count goes from 1 to 7 representing the letters in the alphabet. But I'm not sure how to do so.
Secound, in my vba script to pull information from specific pages i say "sheet1.activate" how can i had the sheet switching during the process to speed up the calculation? and last but not least,
If Cells(1, locd) = "2008" Then
When i run my script, i get a runtime error 1004 application-defined or object defined error. The weird thing is, i can move what line it is on and then the macro will run ONCE and then it breaks again with the same error for that specific piece of code.
I need to know from the combinations below which are the 2 numbers that appeared the most. Example....
View 4 Replies View RelatedI have a workbook that will have a different number of sheets every time. All of the sheets have the same format. I have a summary sheet in which I would like to sum the total of Sheet1 thru the Last sheet in every cell from B12 to B24, then I am going to move on to other columns.
I am getting the same error everytime "Object doesn't support this property or method" and the error is #438.
I have tried different formulas, but none of them are working. Here is my code......
Sub FillSumSht()
Dim wb As Workbook
Dim sSheet As Worksheet
Dim LstShtNm As String
Dim LstSheet As Worksheet
Dim TotalSheets As Long
Dim s As Integer
Dim n As Integer
I'm working with 4 sheets:
Map1: contains a mapping table from old values to new values ( Name)
Map1: contains a mapping table from old values to new values (Location)
Input: contains a table with 3 columns, Amount/Old Name/Old Location
Output: contains a table with 3 columns, Amount/New Name/New Location
I need to create the sheet called Output, which will have the same Amount column as Input sheet but will do a vlookup to get New Name and Location values using the Map1 and Map2 sheet.
Can use a highlighted range in a macro or a formula.
Just really want to be able to highlight a range of cells in column B and maybe click a button to launch a userform with a label on. The label would have the average of the highlighted cells.
Does this sound possible?
I’m wondering if it possible to have a variable in a Formula. I was looking around, but non of the other examples I found was working. The code I was trying is:
Sub All()
Dim lngDataRows As Long
Dim lngDataRowsSum As Long
' add sum
lngDataRowsSum = Range("A5").End(xlDown).Row
Range("A" & lngDataRowsSum).Offset(1, 0).FormulaR1C1 = "Sum"
Range("M" & lngDataRowsSum).Offset(1, 0).FormulaR1C1 = "=sum(M6:M & lngdatarowssum)"
End Sub
Another code I tried was from this thread
Sub All()
Dim lngRowsBottom As Long
Dim lngRowsTop As Long
' add sum
lngDataRowsSum = Range("A5").End(xlDown).Row
Range("C10").formula = "=sum(R["&lngrowstop&"]C:R["&lngrowsbottom&"]C)"
End Sub
The error message is: “Compile error: Expected: enf of statement” and the part “[C:R[“ is highlighted. Tried various ways to solve it but nothing was working.
Does anyone of you know how to get it up and running?
My macro inserts the formulas correctly up until the last loop where I get an Application Defined or Object Defined error on the .FormulaR1C1 line. The msgbox returns the correct values.
iCtr = 0 'data starts on 1
For c = 6 To 14 'columns F to N
iCtr = iCtr + 1
MsgBox ("Column " & c & " Index " & iCtr)
With . Cells(6, c)
.HorizontalAlignment = xlCenter
.NumberFormat = "#,##0;;"
.FormulaR1C1 = "=IF(ISBLANK(INDEX(MyNamedRange," & iCtr & ",1)),"""",'" & Replace(MainPage.Name, "'", "''") & "'!R" & NextRow & "C6)"
End With
Next
I currently have the following code to copy and transpose data from one worksheet to another:
Range("E3:E6,E10:E53").Select
Selection.Copy
Sheet3.Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues, Transpose:=True
What I would like to do is add to this code. I would like to add the following formula to the cell at the end of that pasted row. =VLOOKUP(Range,LeaveIndicator,6,FALSE). In this case the Range needs to be Row D and the last row of sheet3.
I'm going to be using a spreadsheet to keep track of where different people are at. So if Person 1 is in Room 3, I will stick a 3 in the box next to their name and then can look at the spreadsheet whenever I need and see what room they are in. When I'm deciding what room to put a person in, though, I need to be able to quickly glance at a list of Room #'s and see what one's are still available. So I have a bank of Room #'s in the spreadsheet....1,2,3, etc.
What I'd like, is some way to set this up so that when I put, for example, "3" in the cell next to "Person 1" the spreadsheet automatically removes "3" from the bank of available Room #'s and when I delete the "3" because the person has left, it adds "3" back to the bank of available Rooms.
I have a mass of data which look something like this:
table removed
and I require the ranges of reference numbers to be listed in a column one above the other, which requires inserting new rows. I also need the date & description columns copied down into the newly inserted rows.
So basically for example I would want the top row to now read:
table removed
and then apply the same procedure to the other ranges below this.
following issue:
The following table is given:
flower
20
rose
flower
21
rose
[Code] ........
Which needs to be turned into:
flower
20
22
rose
flower
31
32
blossom
tree
1
3
apple
The last column is the one that dictates when a new range of numbers start. There should be one range of numbers for Rose, One range for Blossom etc.
I have a spread sheet with large number of data, problem is all are in various currency so rather than typing =#####.##/a1 in every cell to get the GBP amount (a1 where my exchange rate is linked) I thought if there is macro can do this job for rme.
So what i need is macro which once run enter the formula after the numbers already in the cell in selected or given range.
I need to paste this formula
=AVERAGEIFS(A1:A1000;A1:C1000;"0";A1:A1000;"A1001") into range of cells so the changes relatively to its position e.g. in column B it will look like this
=AVERAGEIFS(B1:B1000;B1:C1000;"0";B1:B1000;"B1001") The macro I recorded will paste formula where I need, but all references remain the same. What should I do to make them change?
I have recorded a macro code for which is as follows. This Macro goes into a worksheet and gives percentile value for a range of data. But this is becoming cubersome as this sheet is 65531 rows and can span multiple spread sheets. Can this be put in a loop of some sort to go through the whole worksheet? ....
View 9 Replies View RelatedIf I have a formula that uses cells that are currently blank - and then run a macro that puts data into those cells - the original formula cell ranges change - even if I put $ within the ranges.
i.e.
Cell A1 has formula = sumproduct(e1:e10>10)
Currently cells E1:E10 are empty
Run the macro
E1:E10 now has data in.
But formula in cell A1 now reads something like =sumproduct(E13:E23>10) or could read =sumproduct(Ref#>10)
using a macro im trying to paste in a sum formula, however this will be pasted onto different sheets and the number of records will be different for each so i cannot use absolute locations. the only constant is that all ranges will start in row I9. when it runs the following code
Range("G" & (ActiveCell.Row)).Select
ActiveCell = "Total"
Range("I" & (ActiveCell.Row)).Select
ActiveCell.FormulaR1C1 = "=Sum(I8:R[-1]C)"
Range("J" & (ActiveCell.Row)).Select
ActiveCell.FormulaR1C1 = "=Sum(J8:R[-1]C)"
Range("I:J" & (ActiveCell.Row)).Select
Selection.Copy
Range("I4:J4").PasteSpecial
it fills in =SUM('I8':I13) how can i make it insert it without the ' ' around the I9? and how can i select the two cells? (again, cannot be absolute..)
I have a formula that works fine in the cell of an Excel spreadsheet but I'm struggling to translate it into VBA (your help please).
The cell formula is:
=If(B2="", "", B2 & " (version: " & F2 & ")")
I want to iterate through all rows in my spreadsheet (about 2000) incrementing the relevant row numbers in the formula @ each pass - eg changing B2 -> B3 -> B4 etc and F2 -> F3 -> F4 etc where column 'B' contains the name of the product and column 'F' contains the version number, resulting in "Product Name (version: 123)" per row.
The closest I've got to this is:
Sub LookupNameInColumnA()
Range("A2").Select
Dim i As Integer
For i = 1 To Selection. CurrentRegion.Rows.Count - 1
ActiveCell.Formula = "=IF(B2="""", """", B2 & "" Version: 999"")" ' problem line?
ActiveCell.Offset(1, 0).Select
Next i
End Sub
This works OK'ish but I want each line to reflect the different data per row. I'm struggling to increment row 'B' and row 'F' in the formula, having tried "B & i + 1" and "F & i + 1" but am getting confused with quotes and concatenating strings within formulas.
I have a spreadsheet that contains the 5 digit numbers in the rows and the columns respecstively. I'd like a formular or macro to change font color for each cell. If the combined value of the 5 rows are greater or less than the combined range 87030 and 87200, the 5 cells will be changed to Red. If:.........
View 4 Replies View RelatedI need a macro, or a formula that can identify if the words in the Words Column (Column A) is contained in Title Column (Column B). If it is, It displays as "Yes". If not, display as "No".
Case is not sensitive.
Words
Title
Displayed?
Christmas
Coworker has chronic hiccups
Yes
Excel
I Love Excel
Yes
Cartman
I Like Turtles
No
Ninja
Oh Christmas Tree
Yes
Tiger
Case of the Mondays
No
Chronic
Cute Monkeys
No
I know ASAP has a feature to do this but I need the code in a bigger macro that I wrote.
EX: -1 needs to be 1
I have been looking through the forums and found the below code, but I have both text and numbers in the same range. I have attached an example of what I need to have converted.
Book1.xlsx