Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default do loop problem

I have written the following code and cannot understand why it does not
run past the first row of information. My worksheet currently has five
rows of data and the select/case works great on the first row but it
does not move to the next row to run select/case [or so I assume]

What am I missing

Dim job As String
Names.Add Name:="OTcal", RefersTo:="=r33:s33", Visible:=True
Do
job = ActiveCell
Select Case job
Case Is = "RehabNorcran"
Range("R44:s44").Select
Selection.Copy
Range("OTcal").Select.Paste
ActiveSheet.Copy
Case Is = "RehabCarman"
Range("R44:s44").Select
Selection.Copy
Range("OTcal").Select
ActiveSheet.Paste
Case Is = "Shop- Day"
Range("R47:s44").Select
Selection.Copy
Range("OTcal").Select
ActiveSheet.Paste
Case Is = "Operation"
Range("r54:s54").Select
Selection.Copy
Range("OTcal").Select
ActiveSheet.Paste
End Select

Loop Until IsEmpty(ActiveCell.Offset(1, 0))
MsgBox "all calcuation is done"


End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default do loop problem

Do
Select Case ActiveCell
Case Is = "RehabNorcran"
Case Is = "RehabCarman"
Case Is = "Shop- Day"
Case Is = "Operation"
End Select

Range(ActiveCell.Offset(1, 0).Address).Select
Loop Until IsEmpty(ActiveCell)


" wrote:

I have written the following code and cannot understand why it does not
run past the first row of information. My worksheet currently has five
rows of data and the select/case works great on the first row but it
does not move to the next row to run select/case [or so I assume]

What am I missing

Dim job As String
Names.Add Name:="OTcal", RefersTo:="=r33:s33", Visible:=True
Do
job = ActiveCell
Select Case job
Case Is = "RehabNorcran"
Range("R44:s44").Select
Selection.Copy
Range("OTcal").Select.Paste
ActiveSheet.Copy
Case Is = "RehabCarman"
Range("R44:s44").Select
Selection.Copy
Range("OTcal").Select
ActiveSheet.Paste
Case Is = "Shop- Day"
Range("R47:s44").Select
Selection.Copy
Range("OTcal").Select
ActiveSheet.Paste
Case Is = "Operation"
Range("r54:s54").Select
Selection.Copy
Range("OTcal").Select
ActiveSheet.Paste
End Select

Loop Until IsEmpty(ActiveCell.Offset(1, 0))
MsgBox "all calcuation is done"


End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default do loop problem

better yet, simply:

ActiveCell.Offset(1, 0).Select

(I never use Offset so I didn't know I could do it that way)


" wrote:

I have written the following code and cannot understand why it does not
run past the first row of information. My worksheet currently has five
rows of data and the select/case works great on the first row but it
does not move to the next row to run select/case [or so I assume]

What am I missing

Dim job As String
Names.Add Name:="OTcal", RefersTo:="=r33:s33", Visible:=True
Do
job = ActiveCell
Select Case job
Case Is = "RehabNorcran"
Range("R44:s44").Select
Selection.Copy
Range("OTcal").Select.Paste
ActiveSheet.Copy
Case Is = "RehabCarman"
Range("R44:s44").Select
Selection.Copy
Range("OTcal").Select
ActiveSheet.Paste
Case Is = "Shop- Day"
Range("R47:s44").Select
Selection.Copy
Range("OTcal").Select
ActiveSheet.Paste
Case Is = "Operation"
Range("r54:s54").Select
Selection.Copy
Range("OTcal").Select
ActiveSheet.Paste
End Select

Loop Until IsEmpty(ActiveCell.Offset(1, 0))
MsgBox "all calcuation is done"


End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default do loop problem

That didn't work, but I may have figured out why.

The process starts with active.cell being b33 - depending on what is in
b33 case determines which formula to paste into r33 and s33.

What I think is happening is after it determines what formula to paste
it stays in the cell that is too be copied and does
Range(ActiveCell.Offset(1, 0).Address).Select

so now I have to figure out how to get it back to b33 - when it is
variable.

any ideas?
Charlie wrote:
better yet, simply:

ActiveCell.Offset(1, 0).Select

(I never use Offset so I didn't know I could do it that way)


" wrote:

I have written the following code and cannot understand why it does not
run past the first row of information. My worksheet currently has five
rows of data and the select/case works great on the first row but it
does not move to the next row to run select/case [or so I assume]

What am I missing

Dim job As String
Names.Add Name:="OTcal", RefersTo:="=r33:s33", Visible:=True
Do
job = ActiveCell
Select Case job
Case Is = "RehabNorcran"
Range("R44:s44").Select
Selection.Copy
Range("OTcal").Select.Paste
ActiveSheet.Copy
Case Is = "RehabCarman"
Range("R44:s44").Select
Selection.Copy
Range("OTcal").Select
ActiveSheet.Paste
Case Is = "Shop- Day"
Range("R47:s44").Select
Selection.Copy
Range("OTcal").Select
ActiveSheet.Paste
Case Is = "Operation"
Range("r54:s54").Select
Selection.Copy
Range("OTcal").Select
ActiveSheet.Paste
End Select

Loop Until IsEmpty(ActiveCell.Offset(1, 0))
MsgBox "all calcuation is done"


End Sub



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
loop problem teepee[_3_] Excel Discussion (Misc queries) 3 December 31st 08 11:09 AM
Loop Problem smandula Excel Programming 0 March 23rd 06 01:51 PM
Loop problem Shawn Excel Programming 3 September 12th 05 11:05 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
Problem with Loop Mike Excel Programming 7 February 26th 04 09:12 PM


All times are GMT +1. The time now is 10:33 PM.

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"