Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi. I fixed the two points.
Sub Macro2() Dim n As Integer Range("D1").Select n = 1 Do 'needed to write the R1C1 formula. ActiveCell.FormulaR1C1 = "=Average(RC[-3], RC[-2])" 'the ActiceCell shifts under the current cell ActiveCell.Offset(1, 0).Select n = n + 1 Loop Until IsEmpty(Cells(n, 1)) End Sub -- Samura "ellis_x " wrote in message ... Hello, I am a newb at VBA programming, but I am trying to get a loop code to run. A simple example in below. Code: -------------------- Sub Macro2() ' This loop runs until there is nothing in the next column Range("D1").Select Dim n As Variant n = 1 Do ActiveCell.FormulaR1C1 = "=Average(Cells(n, 1), Cells(n, 2))" ActiveCell.Offset(0, 2).Select n = n + 1 Loop Until IsEmpty(Cells(n, 1)) End Sub -------------------- Hopefully someone here will be able to spot what is wrong with what I've done here and be kind enough to help. What is posted here, just puts "=Average(Cells(n, 1), Cells(n, 2))" iin each of the cells - instead of calculating the number . Using Code: -------------------- ActiveCell.FormulaR1C1 = "=Average(Cells(n, 1).Value, Cells(n, 2).Value)" -------------------- comes back with an error. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to Loop some code | Excel Discussion (Misc queries) | |||
VB for excel, how do I loop through code | Excel Discussion (Misc queries) | |||
Excel VBA code required (for.......next loop) | Excel Programming | |||
VBE code in a loop | Excel Programming | |||
Excel VBA - Help with a loop, compare, delete problem | Excel Programming |