View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Incidental Incidental is offline
external usenet poster
 
Posts: 226
Default Multiple printing of cell data onto new worksheet

Hi Anthony

The code below would be one way of doing what you want (i think
anyway), what i have done is created the range on the first sheet and
started to work through each cell of the range using the offset method
to pass the number of tickets bought to the variable n i then use this
variable to control the amount of times i want the loop to run that
will add the name to the next empty cell in column a of the sheet
named "Draw". i hope this is clear enough for you but if you have any
problems reply and i will comment the code to explain better what it
is doing.

Option Explicit
Dim i, n As Integer
Dim MyRng, MyCell As Range
Dim NameCell As Range
Private Sub CommandButton1_Click()

Sheets(1).Activate

Set MyRng = [A1:A50]

For Each MyCell In MyRng

If MyCell.Offset(0, 2).Value 0 Then

n = MyCell.Offset(0, 2).Value

Sheets("Draw").Activate

For i = 1 To n

If [A1].Value "" Then

Set NameCell = [A65535].End(xlUp).Offset(1, 0)

Else

Set NameCell = [A1]

End If

NameCell.Value = MyCell.Value

NameCell.Offset(0, 1).Value = MyCell.Offset(0, 1).Value

Next i

End If

Next MyCell

End Sub

hope this helps

Steve