Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I am a newb at VBA programming, but I am trying to get a loop code t 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 wha 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. Cheers Elli -- Message posted from http://www.ExcelForum.com |
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 |