LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default strange printing/looping problem

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.

--
Message posted from http://www.ExcelForum.com

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Scrolling Looping Problem Nick Wakeham Excel Discussion (Misc queries) 0 June 12th 07 01:42 PM
Macro looping problem. [email protected] Excel Discussion (Misc queries) 8 October 26th 06 02:44 PM
A Strange Printing Problem PA New Users to Excel 2 July 21st 06 09:15 PM
complex looping problem Max Bialystock Excel Programming 16 April 10th 04 01:56 PM
Looping Problem Todd Huttenstine[_3_] Excel Programming 5 January 25th 04 12:51 AM


All times are GMT +1. The time now is 06:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"