LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Loop problem

Hi, Below is my poor attempt of copying a range (invoices) to another page.
The idea is:- the macro changes a number (from 1) copies a range onto
another sheet, then changes the number 1 to 2 (reformulates) copies the same
range and places beneath the last data. I want it to keep doing this until it
reaches 60 then stops.
Can someone please help and correct the code for me?
John

Sub Macro2()
Application.ScreenUpdating = False
Sheets("Delivery Note").Select
' On the worksheet this cell will say Stop when another number reaches a
certain number
Range("R5").Select
Do Until ActiveCell.Text = "Stop"
' Cell L3 increments by 1 using the next bit of code
Range("L3").Select
Selection.Copy
Range("R3").Select
Selection.PasteSpecial Paste:=xlPasteValues
' The next piece is to wait for the formula's to catch up
Application.Wait Now + TimeValue("00:00:01")

Range("S2").Select
If ActiveCell = 1 Then
Range("R2").Select
If ActiveCell = 1 Then
Application.Goto Reference:="inv_a"
Selection.Copy
Sheets("Inv").Select
iFreeRow = Cells(Rows.count, "B").End(xlUp).Row
Cells(iFreeRow + 1, "B").PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets("Delivery Note").Select
End If

If ActiveCell = 2 Then
Application.Goto Reference:="inv_b"
Selection.Copy
Sheets("Inv (2)").Select
iFreeRow = Cells(Rows.count, "B").End(xlUp).Row
Cells(iFreeRow + 1, "B").PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets("Delivery Note").Select
End If

End Sub
 
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 Cody Excel Programming 0 July 28th 05 08:12 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
For Next loop problem Jo[_6_] Excel Programming 2 June 26th 04 12:41 AM
Loop Problem Todd Huttenstine Excel Programming 10 April 12th 04 06:15 PM
For..Next loop problem Dwaine Horton Excel Programming 1 February 18th 04 12:12 AM


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