# Subtract Ranges Without Makeing Them An Array

Jun 5, 2009
if i can subtract ranges without makeing them an array?

ex:

x = ThisWorkbook.Sheets("Raw Data (2)").Range("C6:C65536")

y = ThisWorkbook.Sheets("Raw Data (2)").Range("N6:N65536")

z = x - y

ThisWorkbook.Sheets("Raw Data (2)").Range("DH6:DH65536") = z

Or do I need to read each range as an array, subtract it and then write it out the the sheet?

View 9 Replies
ADVERTISEMENT
Dec 4, 2012

How can I subtract a series of numbers from an array. example.

Code:

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

13

14

25

26

37

39

[Code] ......

=ABS(1-B2) C2,D2,E2,F2 AND G and after start again with =abs(2-B2:G2)

I want to know how to do this for example until 60, I mean 60 minus the row B:G

View 1 Replies
View Related
Apr 15, 2008

I did this a couple of years ago but can't remember how I did it.

PAG CLCMCN9000Spreadsheet FormulasCellFormulaCL9=J87CM9=J89CN9=J90 Excel tables to the web >> Excel Jeanie HTML 4

I need to extend the formula starting in CO9 with =J91, =J92, etc. all the way to about another 150 cells in row 9.

I have tried makeing "J" absolute but that does not work.

View 9 Replies
View Related
Jul 17, 2008

Is it possible to make an named array constant from named constants to use in a lookup?

Eg

I have defined the following constants in Names:

Text1 = "AAAAAAAAAA"

Text2 = "BBBBBBBBBBB"

Num1 = "1234567890"

Num2 = "0987654321"

And would like to make the following array constant in Names:

Arr = {Text1,Num1;Text2,Num2}

However, it does not work.

I am using Excel 2007 by the way and the above values are made up.

View 9 Replies
View Related
Jun 4, 2009

I am trying to copy and paste between workbooks that are defined in an array. However, I get an out of range error when the code first reaches the line Workbooks(Wkbk(WkbkNum)).Activate.

Sub Gather_Risks()

Dim MasterRow As Integer ' Declares row number in Master Worksheet

Dim RowNum As Integer ' Declares row number in active array worksheet

Dim Wkbk(13) As String

MasterRow = 3

WkbkNum = 0

' Declare Wkbk array

Wkbk(0) = "G:Catering-RiskRegister-0409.xls"

Wkbk(1) = "G:CFO-RiskRegister-0409.xls"

Wkbk(2) = "G:Freight-RiskRegister-0409.xls"

Wkbk(3) = "G:GCA-RiskRegister-0409.xls"

Wkbk(4) = "G:IT-RiskRegister-0409.xls"

Wkbk(5) = "G:People-RiskRegister-0409.xls"

Wkbk(6) = "G:Regional-RiskRegister-0409.xls"

StartAgain:

Workbooks.Open (Wkbk(WkbkNum))

RowNum = 3

Do Until WorksheetFunction.CountIf(Rows(RowNum), "") = 0

View 9 Replies
View Related
Oct 3, 2007

I would like to set up VBA codes to generate a variable number of transition matrices. I would like to know how I can define dynamic ranges instead of coding each and every range. In the codes below, I have to define each range one by one instead of using a loop.

Sub TransitionMatrix()

Dim P1 As Range

Set P1 = Cells(2, 2).Resize(3, 3)

Dim P2 As Range

Set P2 = P1.Offset(5, 0).Resize(3, 3)

P2.Cells(0, 1) = "P2"

For i = 1 To 3

For j = 1 To 3

P2.FormulaArray = "=MMULT(" & P1.Address & "," & P1.Address & ")"

P2.BorderAround Weight:=xlMedium

Next j

Next i

Dim P3 As Range

Set P3 = P2.Offset(5, 0).Resize(3, 3)........................

View 3 Replies
View Related
Jul 2, 2009

My problem is :

1.In G Column I put logic for Fail and Obtained Marks.

G2=IF(COUNTIF(B2:F2,">=60")=5,SUM(B2:F2),"Fail")

2. Now in H column I want use this formula which I obtained from this forum

H2=SUMPRODUCT((G$2:G$7>G2)/COUNTIF(G$2:G$7,G$2:G$7&""))+1

To get the position of Students.

But the text value "fail" in the G2:G7 getting Position No. 1 and i've noticed the reason by using evaluate formula as well.

3. I got solution by changing "Fail" with 0 by creating column I and then column H put this formula ........

View 14 Replies
View Related
Sep 10, 2012

I'm trying to create a single array from multiple ranges... I'm not sure what syntax to use:

Code:

Dim dat4() As Variant

Set r = Sheet13.Range("rsqlassetid")

Set r2 = Sheet13.Range("rsqlparentcat")

dat4() = (r , r2)

I can create an array with multiple columns from a range if the columns are next to each other but in this instance they're not.

These 2 ranges both have the same number of rows and I'm trying to combine them into a 2 column array, but not sure how to make it work without looping, rediming the array and using a secondary array to preserve the data...

View 9 Replies
View Related
Aug 2, 2014

I have tried:

Code:

With Sheet1

x = .[b7:i16,b19:i23,b27:i32].Value

But that only loads the first range (.[b7:i16]).

This does work:

Code:

.[b7:i16,b19:i23,b27:i32].Copy .[z1]: x = .[z1:ag21]: .[z1:ag21].Clear

I would rather avoid having to copy/paste, load the array, then clear. Is there a way to load the array directly?

View 2 Replies
View Related
Apr 6, 2008

way for excel to automatically identify ranges given the first cell of an array.I guess the concept is simple:

Lets say given A1 is the top left corner then excel should look the offset columns for values and/or formulas,when nothing is found and a blank cell is found then that's the border column.Then same goes for rows,and when bootom row is found then the bootom right cell can be identified and array/range is found!

So how can that be done inside excel?

View 9 Replies
View Related
Jul 6, 2009

I want to get students positions in a class like 1st, 2nd, 3rd, etc. There can be two 1st position and 2 2nd positions at a time .

1.In G Column I put logic for Fail and Obtained Marks.

G2=IF(COUNTIF(B2:F2,">=60")=5,SUM(B2:F2),"Fail")

2. Then i made array formula in column H to get the position

={SUMPRODUCT((IF(ISNUMBER($G$2:$G$7),$G$2:$G$7,0)>N(G2))/COUNTIF(G$2:G$7,G$2:G$7&""))+1}

Some improvement to write fail & position

={IF(COUNTIF(B3:F3,">=60")5,"Fail",SUMPRODUCT((IF(ISNUMBER($G$2:$G$7),$G$2:$G$7,0)>N(G3))/COUNTIF(G$2:G$7,G$2:G$7&""))+1)}

And more work to get total marks & position and Fail at the same time......

={IF(COUNTIF(B2:F2,">=60")5,"Fail",SUM(B2:F2)&"-"&SUMPRODUCT((IF(ISNUMBER($G$2:$G$7),$G$2:$G$7,0)>N(G2))/COUNTIF(G$2:G$7,G$2:G$7&""))+1)}

Now I wounder that is there a way to do all calculations in column H without using column G

By replacing (if there is any method) G2, G3, G4 etc. with Sum(B2:F2); Sum(B3:F3);Sum(B4:F4) etc. in below formula

={SUMPRODUCT((IF(ISNUMBER($G$2:$G$7),$G$2:$G$7,0)>N(G2))/COUNTIF(G$2:G$7,G$2:G$7&""))+1}.....................

View 9 Replies
View Related
Nov 19, 2013

I am trying to do something that sounds fairly straightforward but have not been able to achieve the final result.

I have a sheet which has multiple range addresses stored in different cells and so far I have been able to pass the Range address to Range variables by looping through a range array. Now I would like to select these multiple ranges. My code looks as below;

VB:

Dim Cnt As Integer

Cnt = Sheets("Sheet1").(Range("1040").Value ' Cnt holds the the total number of ranges to be specified in Sheet1

Dim RStr(1 To 80) As String ' This will hold the range addresses specified in Sheet1 in cells C1041 to C1120. Upto 80 range addresses could be specified.

[SIZE=2] Dim Rng(1 To 80) As Range ' This will store the ranges based on the range addresses stored in RStr()

Dim i, j As Integer,

[Code]...

I am not sure on how to select multiple ranges using range array hence tried Union() however it is obviously not correct and throws an error.

View 2 Replies
View Related
May 21, 2008

I am trying to enter only the named ranges in the active worksheet into an Array.

The amount of named ranges can be from 4 to 7 per sheet.

I'm self taught at VB (This posts on this forum have taught me - thank you!) and have got the below code working on a Workbook - but not on a worksheet level.

ActiveSheet.Names.Count returns nothing, changing to ThisWorkBook.Names.Count returns the sum of all .Names in the workbook.

Sub aTest()

Dim sArray() As String

Dim sJoin As String

Dim y As Long

x = 1

y = ActiveSheet.Names.Count

z = ActiveSheet.Name

View 3 Replies
View Related
Apr 28, 2012

I am trying to subtract an amount from a cell until it reaches 0, then move and subtract from the next amount, and so on.

AmountFixed BudgetedResult53.50Subtracted 5 tell it hit zero1.30Subtracted remaining amount until zero43.8Subtracted remaining amount until zero3.8 was left over without hitting zero is good. Is there formula for this?

View 6 Replies
View Related
Oct 25, 2007

I need help creating a macro that will search through my excel spreadsheet and for every instance where column A isn't empty it should cut a range of columns from that row and paste them in a different range of columns in the row before it. It should then delete the row that it cut the columns from and keep searching until it has done this for the whole worksheet. I can modify which range of columns are needed, but it has been so long since I've worked with excel macros that I haven't been able to do it.

View 5 Replies
View Related
Dec 28, 2013

I need a formula to do the following

Subtract I62 from I62 only if F62 contains P/UT and put answer of subtraction in L62.

Cells are in Time format

View 8 Replies
View Related
Jan 28, 2008

Firstly i am running Excel 2003 (at work)

Now my problem is that i have been asked to make a spreadsheet about Printer and Fax Cartridges (Zzzzz) but i do not know how to do the sum.

this is how my Spreadsheet looks like this (cartidge amount etc all on top line of spreadsheet)

(Hp45 etc all down left hand side) ...

View 9 Replies
View Related
Oct 24, 2008

Seems that when I subtract a future date from NOW() and format the cell d:hh:mm that the result is 1 day off. So if I subtract NOW() (today is 10/24) from 10/25/08 it returns a 1 for the d when I would expect it to be zero.

View 14 Replies
View Related
Apr 13, 2009

I have 2 cells in a row that are times, it has been a while since I did any work in excel. I want to take the first cell as start Time, the second cell is end time and I need to subtract them and put the total in a cell called Hours. What is the correct format to use and how would I do the subtraction.

Generally start time will be AM and End Time will be PM.

View 8 Replies
View Related
Jun 1, 2009

How do I add and subtract hours minutes and seconds?

I’m writing a program to find when the sun is directly overhead. I’m doing this so that I can find the true north/south line. In the example on my program, at the town of Farmington, a plumb bob will cast a shadow on the north/south line at 11:51:39 on June 16

View 9 Replies
View Related
Dec 30, 2009

Cell D10 to be a formula that; Looks at Cells E13:E38 and if in this range the text "Sick" appears looks at the adjacent cell H13:H38 (which has a numeric value). It will then take that value and subtract it from D8.

I will have to do this for 2 other text strings as well, Vacation and Holiday.

View 2 Replies
View Related
Feb 20, 2010

CELL A1=45

I want CELL A2 to be a blank cell which people can enter a number in that will decrease the value of A1 and once that value is entered, it would return to a blank cell. CELL A3 would be used in the same fashion except to increase the value of A1

what would a formula for this look like?

View 10 Replies
View Related
Jun 23, 2014

im trying to subtract from two cells. see below

i have two cells, lets say A1 which has number 10 in it, and cell B1 which has -1 in it, but when i use this formula in cell C3 =sum(A1 - B1) It add it on when there's a minus sign in front of the number is there a way around this?

View 2 Replies
View Related
Dec 6, 2006

Im working on a time schedule form for my work. It all works good but it have one little error.

Lets say it looks like this

cell a1 has start time 22:00 and a2 has a end time 07:00. i know that i can switch the cells in the formula =sum((a1-a2)*24). like this i´ll get a negativ answer and that f.cks up the totalt becuse of the negativ answer i get.

is there a way to get 7:00 - 22:00 and 22:00 - 7:00 to calculate as positiv with one formula?

View 9 Replies
View Related
Apr 23, 2007

I have a column with start date and another next to it with end date. I now want a third column that gives the number of days alloted. I tried

=G6-F6 and that didn't work. What should I do?

View 9 Replies
View Related
Dec 1, 2007

I need to be able to determine a departure time based on: Appointment - Transit time - 1 hour buffer......Clear as mud?

I tried using =SUM(M2-N2)-1, but being a noob, it's not working and I am lost, yes I admit it, I'm lost...

I do have all the cells format set [h]:mm

View 9 Replies
View Related
Apr 25, 2006

I want to return the previous month in long text format and then use it as part of a file name. when i run the below the subtraction takes one day away from the current date and the msgbox displays "January". I want to return "March"

Sub test

Dim MyMonth

Dim TradesMonth

MyMonth = Month(Date) - 1

TradesMonth = Format(MyMonth, "mmmm")

msgbox TradesMonth

End Sub

View 2 Replies
View Related
Nov 27, 2006

I have 3 columns. A B and C. In column C I want to input the answer to a formula into each cell using data from cells in their respective rows,

For. e.g.

Cx= Ax- (Bx X 0.8).

I want to be able to input this formula somewhere that will automatically fill out the cells in column C.

Column C is 20 cells long so x would range from 1 to 20.

View 5 Replies
View Related
Nov 15, 2012

I have travel data for hundreds of cars. Col A has the car ID number. Col B has the date. Col C has the distance of a journey. Column D, has the total distance traveled on a given date for a given car.

In Column E, I'm trying to calculate the remaining distance to travel "prior" to the journey being made.

I a have attached an example. [URL] ....

So in column E, prior to the first journey (9km) being made there is 19 km still to travel in the data. And for the second journey the is 10 km left to travel.

View 1 Replies
View Related
Jul 30, 2014

I'm working on a budget and financial calculator

I've already got it set up to calculate my pay and deduct taxes and all my bill and tell me how much I have left at the end of the month, now I am trying to get it set up to tell me how much will be left out of each check I get based on what day my bills are due.

Essentially what i want is I7 is the cell for my first check of the month and K7 is my second check, Column H shows my due dates for each bill, column A is the price on each bill so what i want is something that is similar to.

If the value if column H is between 5 and 19 then deduct the price in column a from I7 (with H and A being the same row) and if the value of column H is 1-4 or 20-31 then deduce the value in column A (with H and A being the same row) from K7.

Another way to put it would be I7 gets deducted the value in column A if column H is between 4-19 otherwise do nothing (with H and A having same row) deduct the value in Column A from K7 if column H is between 1-4 or 20-31 otherwise do nothing.

View 3 Replies
View Related