Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Making calculations down one column while moving down another
Hello,
First I need to move down a column starting at A5 until there is no data in a row to identify the numbers of rows . As I am moving down the row, I need to calculate cell C5 = M5-M4. Then cell C6=M6-M5 and so on. Thanks in advance, JV |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Making calculations down one column while moving down another
To keep the formula intact:
Sub testHere() For i = 5 To Cells(Rows.Count, 1).End(xlUp).Row Cells(i, 3).FormulaR1C1 = "=RC[10]-R[-1]C[10]" Next i End Sub To not keep the formula: Sub testAgain() For i = 5 To Cells(Rows.Count, 1).End(xlUp).Row Cells(i, 3).Value = Cells(i, 13).Value - _ Cells(i, 13).Offset(-1, 0).Value Next i End Sub JV wrote: Hello, First I need to move down a column starting at A5 until there is no data in a row to identify the numbers of rows . As I am moving down the row, I need to calculate cell C5 = M5-M4. Then cell C6=M6-M5 and so on. Thanks in advance, JV |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Making calculations down one column while moving down another
JV,
Try this Sub JV() Range("A5").Select If ActiveCell < "" Then Do Until ActiveCell = "" 'c5=m5-m4 ActiveCell.Offset(0, 2) = ActiveCell.Offset(0, 12) - ActiveCell.Offset(-1, 12) ActiveCell.Offset(1, 0).Select Loop Else Exit Sub End If End Sub "JV" wrote: Hello, First I need to move down a column starting at A5 until there is no data in a row to identify the numbers of rows . As I am moving down the row, I need to calculate cell C5 = M5-M4. Then cell C6=M6-M5 and so on. Thanks in advance, JV |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Making calculations down one column while moving down another
JR, while your code may produce the correct results, making selections
like that is generally considered a bad coding practice and should be avoided if at all possible. In this case, there is no need to make selections of any kind. JRForm wrote: JV, Try this Sub JV() Range("A5").Select If ActiveCell < "" Then Do Until ActiveCell = "" 'c5=m5-m4 ActiveCell.Offset(0, 2) = ActiveCell.Offset(0, 12) - ActiveCell.Offset(-1, 12) ActiveCell.Offset(1, 0).Select Loop Else Exit Sub End If End Sub "JV" wrote: Hello, First I need to move down a column starting at A5 until there is no data in a row to identify the numbers of rows . As I am moving down the row, I need to calculate cell C5 = M5-M4. Then cell C6=M6-M5 and so on. Thanks in advance, JV |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Making calculations down one column while moving down another
JW,
Thanks for tip. JR "JW" wrote: JR, while your code may produce the correct results, making selections like that is generally considered a bad coding practice and should be avoided if at all possible. In this case, there is no need to make selections of any kind. JRForm wrote: JV, Try this Sub JV() Range("A5").Select If ActiveCell < "" Then Do Until ActiveCell = "" 'c5=m5-m4 ActiveCell.Offset(0, 2) = ActiveCell.Offset(0, 12) - ActiveCell.Offset(-1, 12) ActiveCell.Offset(1, 0).Select Loop Else Exit Sub End If End Sub "JV" wrote: Hello, First I need to move down a column starting at A5 until there is no data in a row to identify the numbers of rows . As I am moving down the row, I need to calculate cell C5 = M5-M4. Then cell C6=M6-M5 and so on. Thanks in advance, JV |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Format for making date calculations | Excel Worksheet Functions | |||
Making calculations with times. | Excel Programming | |||
making daily calculations | Excel Discussion (Misc queries) | |||
Freezing the data in a column and moving the calculations to the next column | Excel Programming | |||
problem with military time and making calculations | Excel Programming |