View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Charles Charles is offline
external usenet poster
 
Posts: 1
Default strange printing/looping problem

Omar78,

Sorry I had other things come up. Here is my solution.
I placed you msg on sheet2 rang a1. For some reason I couldn't get th
lable to change after each print.

Hope this works for you.

Option Explicit
Public x As Long
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim rng As Range
Dim ans As String
Set rng = Worksheets("Sheet1").Cells(1, 1).CurrentRegion
For x = 1 To rng.Rows.Count
If rng(x, 2) = rng(x, 3) Then
Worksheets("Sheet2").Activate
Range("A1").Value = "congrats" & " " & rng(x, 3)
ans = MsgBox("Do You want to print?" & " congrats" & " "
rng(x, 3), vbYesNo)
If ans = vbYes Then
With Sheets("sheet2")
Worksheets("Sheet2").PrintOut
Range("A1").Value = ""
End With
End If
Else
Sheets("Sheet2").Activate
Range("A1").Value = "BadLuck" & " " & rng(x, 3)
ans = MsgBox("Do You want to print?" & " BadLuck " & " "
rng(x, 3), vbYesNo)
If ans = vbYes Then
With Sheets("sheet2")
Worksheets("Sheet2").PrintOut
Range("A1").Value = ""
End With
End If
End If
Next
End Su

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