Conditional Lookup and copy loop between worksheets

  • Thread starter Thread starter David S
  • Start date Start date
D

David S

Can anyone point me in the right direction to achieve the following

1 Workbook
2 Work sheets

Sheet 1

A1 - Txt1 Title
B1 - Txt2 Title
C1 - Val1 Title

A2A? - Txt1 TextString
B2B? - Txt2 Textstring
C2C? - Val1 (Null, 0,1 or 999)

? - min of 2, max unknown


Sheet 2

Command button to do the following

counter = 2
Loop until Sheet1-Ccounter = 999
Examine Sheet1-Ccounter
If Sheet1-Ccounter = 1
then
copy Sheet1-Acounter contents to Sheet2-Gcounter
copy Sheet1-Bcounter contents to Sheet2-Hcounter
counter = counter + 1
else
counter = counter+1

Thank you
 
I wasn't exactly clear on what you wanted, but the
following should put you close.

Merjet

Private Sub CommandButton1_Click()
Dim iCt1 As Integer
Dim iCt2 As Integer
iCt1 = 1
iCt2 = 1
Sheets("Sheet2").UsedRange.Clear
Do
iCt1 = iCt1 + 1
If Sheets("Sheet1").Cells(iCt1, 3) = 1 Then
iCt2 = iCt2 + 1
Sheets("Sheet1").Range("A" & iCt2 & ":C" & iCt2).Copy _
Destination:=Sheets("Sheet2").Range("A" & iCt2)
End If
Loop Until Sheets("Sheet1").Cells(iCt1, 3) = ""

End Sub
 
Back
Top