loop until questions

  • Thread starter Thread starter kimt
  • Start date Start date
K

kimt

I have a sheet that prints out time cards at my request. Currently, th
code does the following (I have simplified it for this example, but i
works perfectly);

sub tcardprint ()

sheets("emp Master").select
range("A1:C55").copy ' current employee info
sheets("print format").select
range("A1").pastespecial xlvalues
sheets("print timecard").select ' formats info to car
format
activesheet.print....copies..1 etc ' prints card for 1st emp
sheets("print format").select
range("A2:B56").copy
range("A1").pastespecial xlvalues ' removes first emp
Sheets("print format").print...

So on and so on...based on this operation (never exceeds 55 employees
if have replicated the steps above 55 times. As a result of severa
formulas, the time cards are automatically updated with start-en
dates, employee #'s, and printed alphabetically.

Problem: the above method prints 55 time cards even if there are onl
40 employees.

Solution: use ' loop until method until sheet("print format"),
cell("A1") = " "

I have tried the following and I am missing something (probably ver
simple...only demonstrating what a simpleton I am).

sub cardsetup()

' prints time cards until print format cell A1 = " "

sheets("emp Master").select
range("A1:C55").copy
sheets("print format").select
range("A1").pastespecial xlvalues
call printcard()

sub printcard()

Dim x as integer

x = 'print format'!("A1")

loop until x = " "

sheets("print timecard").select
activesheet.print....copies..1 etc
sheets("print format").select
range("A2:B56").copy
range("A1").pastespecial xlvalues

Elseif
end

anyway...seem to be missing something, and after several attempts hav
mentally faded to blank. Thanks for your help.

Ki
 
Kim,

Try something like

Sub printcard()

Dim x As Range

x = Range("A1")

Do
Sheets("print timecard").Select
activesheet.print....copies..1 etc
Sheets("print format").Select
Range("A2:B56").Copy
Range("A1").PasteSpecial xlValues

Elseif
End
x.Offset(1, o0).Select
Loop Until x = " "

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top