Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Do Until Loop

I'm still not good with setting up loops. I'm trying to create a simple
macro to sum the values in columns L through O, and put the results in Column
P. i want the loop to run until it detects blanks in Column K.

Sub FillDown()
Range("P2").Select
Do Until ActiveCell.Offset(-5, 1) = ""
ActiveCell.FormulaR1C1 = "=SUM(RC[-4]:RC[-1])"
ActiveCell.Offset(1, 0).Select
Loop
End Sub


Please help!
Thanks,
Ryan--
--
RyGuy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Do Until Loop

hi
try this....
Sub FillDown()
Dim r As Range
Dim rd As Range
Dim ro As Range

Set r = Range("K2")
Do While Not IsEmpty(r)
Set rd = r.Offset(1, 0)
Set ro = r.Offset(0, 5)
ro.FormulaR1C1 = "=SUM(RC[-4]:RC[-1])"
Set r = rd
Loop
End Sub

varibles work much better than activecell. it also speeds up the macro
because you not selecting anything.

Regards
FSt1

"ryguy7272" wrote:

I'm still not good with setting up loops. I'm trying to create a simple
macro to sum the values in columns L through O, and put the results in Column
P. i want the loop to run until it detects blanks in Column K.

Sub FillDown()
Range("P2").Select
Do Until ActiveCell.Offset(-5, 1) = ""
ActiveCell.FormulaR1C1 = "=SUM(RC[-4]:RC[-1])"
ActiveCell.Offset(1, 0).Select
Loop
End Sub


Please help!
Thanks,
Ryan--
--
RyGuy

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Do Until Loop

Awesome, simply awesome!
Thanks!

--
RyGuy


"FSt1" wrote:

hi
try this....
Sub FillDown()
Dim r As Range
Dim rd As Range
Dim ro As Range

Set r = Range("K2")
Do While Not IsEmpty(r)
Set rd = r.Offset(1, 0)
Set ro = r.Offset(0, 5)
ro.FormulaR1C1 = "=SUM(RC[-4]:RC[-1])"
Set r = rd
Loop
End Sub

varibles work much better than activecell. it also speeds up the macro
because you not selecting anything.

Regards
FSt1

"ryguy7272" wrote:

I'm still not good with setting up loops. I'm trying to create a simple
macro to sum the values in columns L through O, and put the results in Column
P. i want the loop to run until it detects blanks in Column K.

Sub FillDown()
Range("P2").Select
Do Until ActiveCell.Offset(-5, 1) = ""
ActiveCell.FormulaR1C1 = "=SUM(RC[-4]:RC[-1])"
ActiveCell.Offset(1, 0).Select
Loop
End Sub


Please help!
Thanks,
Ryan--
--
RyGuy

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
Naming Worksheets - Loop within a loop issue klysell Excel Programming 5 March 29th 07 05:48 AM
Naming Worksheets - Loop within a loop issue klysell Excel Programming 0 March 27th 07 11:17 PM
(Complex) Loop within loop to create worksheets klysell Excel Programming 1 March 20th 07 12:03 AM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM


All times are GMT +1. The time now is 02:25 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"