#1   Report Post  
Posted to microsoft.public.excel.misc
Hru48
 
Posts: n/a
Default looping trouble


Hey all,

I'm trying to get this formula to loop around putting the result in
column E until column D is empty but i've tied my brain in a knot, can
someone point out where i'm going wrong,

thanks!!

Sub FUGGLE()
Dim K As Long

Sheets("EL").Select
Range("D8").Select


Do Until ActiveCell.Value = ""
'Do Until ActiveCell.Offset(0, -1).Value = ""

ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=(RC[-1]/R3C[-1])*100"

ActiveCell.Offset(1, 0).Select

K = K + 1

Loop


--
Hru48
------------------------------------------------------------------------
Hru48's Profile: http://www.excelforum.com/member.php...o&userid=24895
View this thread: http://www.excelforum.com/showthread...hreadid=541576

  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student
 
Posts: n/a
Default looping trouble

You need to move back before you move down:


starting at D8 you move across to E8 and deposit the formula.
you then move down to E9 (NOT BACK TO D8). However, E9 is empty, so the
loop stops
--
Gary's Student


"Hru48" wrote:


Hey all,

I'm trying to get this formula to loop around putting the result in
column E until column D is empty but i've tied my brain in a knot, can
someone point out where i'm going wrong,

thanks!!

Sub FUGGLE()
Dim K As Long

Sheets("EL").Select
Range("D8").Select


Do Until ActiveCell.Value = ""
'Do Until ActiveCell.Offset(0, -1).Value = ""

ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=(RC[-1]/R3C[-1])*100"

ActiveCell.Offset(1, 0).Select

K = K + 1

Loop


--
Hru48
------------------------------------------------------------------------
Hru48's Profile: http://www.excelforum.com/member.php...o&userid=24895
View this thread: http://www.excelforum.com/showthread...hreadid=541576


  #3   Report Post  
Posted to microsoft.public.excel.misc
Hru48
 
Posts: n/a
Default looping trouble


So how was I meant to put it?


--
Hru48
------------------------------------------------------------------------
Hru48's Profile: http://www.excelforum.com/member.php...o&userid=24895
View this thread: http://www.excelforum.com/showthread...hreadid=541576

  #4   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student
 
Posts: n/a
Default looping trouble

Sub FUGGLE()
Dim K As Long

Sheets("EL").Select
Range("D8").Select


Do Until ActiveCell.Value = ""
'Do Until ActiveCell.Offset(0, -1).Value = ""

ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=(RC[-1]/R3C[-1])*100"

'move back to D first!!
ActiveCell.Offset(0, -1).Select
ActiveCell.Offset(1, 0).Select

K = K + 1

Loop
End Sub


--
Gary''s Student


"Hru48" wrote:


So how was I meant to put it?


--
Hru48
------------------------------------------------------------------------
Hru48's Profile: http://www.excelforum.com/member.php...o&userid=24895
View this thread: http://www.excelforum.com/showthread...hreadid=541576


  #5   Report Post  
Posted to microsoft.public.excel.misc
Hru48
 
Posts: n/a
Default looping trouble


Ok got it thanks!

One more thing though, I have three blocks of these to do - is there
anyway I can write them all into one sub?

say this one start on d8 and the next one would be g8 next i8?


--
Hru48
------------------------------------------------------------------------
Hru48's Profile: http://www.excelforum.com/member.php...o&userid=24895
View this thread: http://www.excelforum.com/showthread...hreadid=541576



  #6   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student
 
Posts: n/a
Default looping trouble

I would set it up with three separate loops, not knowing if there are as many
items in the other columns as in D.


I also have to admit that it is easier to replicate the code than to re-work
it into a more general form. (a good programmer would create a sub and call
it three times)
--
Gary's Student


"Hru48" wrote:


Ok got it thanks!

One more thing though, I have three blocks of these to do - is there
anyway I can write them all into one sub?

say this one start on d8 and the next one would be g8 next i8?


--
Hru48
------------------------------------------------------------------------
Hru48's Profile: http://www.excelforum.com/member.php...o&userid=24895
View this thread: http://www.excelforum.com/showthread...hreadid=541576


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
Trouble Forecasting PaulW Excel Discussion (Misc queries) 1 April 26th 06 03:24 PM
Looping in VB with cell ranges Freeman Excel Worksheet Functions 2 January 22nd 06 12:14 PM
UGH! Trouble downloading, and opening anything cali Excel Discussion (Misc queries) 1 December 15th 05 06:36 AM
looping question luke New Users to Excel 4 June 3rd 05 01:19 PM
Trouble opening an Excel file that contains macros JohnR Excel Worksheet Functions 1 March 8th 05 08:09 PM


All times are GMT +1. The time now is 06:04 AM.

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

About Us

"It's about Microsoft Excel"