O
Omar78
Hello,
i have 2 sheets
Sheet1 has 3 columns - Class, Attendance, Target
Sheet2 has a label whose caption depends on the data from sheet1. ther
is also a command button on sheet2
Private Sub CommandButton1_Click()
Dim n
n = 1 'assumes first row of your data on Sheet1
Sheets("Sheet1").Select
Do Until n = 4 'only 3 rows of data at the moment
If Cells(n, 2) >= Cells(n, 3) Then
Sheets("Sheet2").Select
Label1.Caption = "congrats" & " " & Sheets("Sheet1").Cells(n
3)
Else
Sheets("Sheet2").Select
Label1.Caption = "bad luck" & " " & Sheets("Sheet1").Cells(n
3)
End If
ActiveSheet.PrintPreview
Sheets("Sheet1").Select
n = n + 1
Loop
End Sub
now when i click on the button i get a print preview box with th
target for row 1..when i click on Close .. the print preview comes bac
with the same data! it should come back with data from row 2..i clic
close again.. the 3rd print preview appears again with the same dat
(data from row 1).
i just cant see what could be the problem here.. i have tried the Wai
method..but no luck..it does appear to be looping through because onc
the program has finished the label in sheet2 displays the data fro
row3.
would appreciate any input.
i have 2 sheets
Sheet1 has 3 columns - Class, Attendance, Target
Sheet2 has a label whose caption depends on the data from sheet1. ther
is also a command button on sheet2
Private Sub CommandButton1_Click()
Dim n
n = 1 'assumes first row of your data on Sheet1
Sheets("Sheet1").Select
Do Until n = 4 'only 3 rows of data at the moment
If Cells(n, 2) >= Cells(n, 3) Then
Sheets("Sheet2").Select
Label1.Caption = "congrats" & " " & Sheets("Sheet1").Cells(n
3)
Else
Sheets("Sheet2").Select
Label1.Caption = "bad luck" & " " & Sheets("Sheet1").Cells(n
3)
End If
ActiveSheet.PrintPreview
Sheets("Sheet1").Select
n = n + 1
Loop
End Sub
now when i click on the button i get a print preview box with th
target for row 1..when i click on Close .. the print preview comes bac
with the same data! it should come back with data from row 2..i clic
close again.. the 3rd print preview appears again with the same dat
(data from row 1).
i just cant see what could be the problem here.. i have tried the Wai
method..but no luck..it does appear to be looping through because onc
the program has finished the label in sheet2 displays the data fro
row3.
would appreciate any input.