Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JV JV is offline
external usenet poster
 
Posts: 22
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Format for making date calculations Cassidy1 Excel Worksheet Functions 3 February 25th 09 09:31 PM
Making calculations with times. Darryl_Neeley[_2_] Excel Programming 2 September 27th 07 04:41 PM
making daily calculations p-nut Excel Discussion (Misc queries) 1 November 2nd 06 06:53 AM
Freezing the data in a column and moving the calculations to the next column Mervyn Thomas Excel Programming 1 December 16th 04 05:28 PM
problem with military time and making calculations soccerstr1 Excel Programming 12 June 23rd 04 12:41 PM


All times are GMT +1. The time now is 11:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"