ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Brake a loop - once more. (https://www.excelbanter.com/excel-programming/338357-brake-loop-once-more.html)

Einar

Brake a loop - once more.
 
Please, can somebody help me with this one and give me an example?

Einar


TomHinkle skrev:


set a counter for number of iteration
use the 'stop' method in the code...

"Einar" wrote:

I have workbook with different prices depending on postal code found in
worksheet €śaddress€ť. Usually we print out more than 100 copies with both
name, address and corresponding price. I want to make a brake in the loop and
verify for every 20th copy.

The question is how?

The macro looks like this:

Sheets("Adress").Select
With Sheets("Adress")
.Range("A12").Copy Sheets("Intern forside").Range("BE14")
.Range("B12").Copy Sheets("Intern forside").Range("BE15")
.Range("C12").Copy Sheets("Intern forside").Range("BE16")
.Range("D12").Copy Sheets("Intern forside").Range("BE17")
.Range("E12").Copy Sheets("Intern forside").Range("BE18")
.Range("F12").Copy Sheets("Intern forside").Range("BE19")
.Range("G12").Copy Sheets("Intern forside").Range("BE20")
.Range("H12").Copy Sheets("Intern forside").Range("BE21")
End With

iEndRow = Sheets("Adress").Cells(Rows.Count, "A") _
.End(xlUp).Row

i = 14

With Sheets("Adress")
For Each cell In Range("A12:H" & iEndRow)
cell.Copy Sheets("Intern").Range("BE" & i)
i = i + 1
If i = 22 Then
Worksheets("Price").PrintOut Copies:=1, Collate:=True
i = 14
End If
Next cell
End With

-------------------

Thanks for help

Einar





All times are GMT +1. The time now is 01:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com