ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   program (https://www.excelbanter.com/excel-programming/362087-program.html)

Fernando Duran[_4_]

program
 
I have an small program with a bug in the second pass to print a spread
sheet, it does the fisrt time without no problems, but the second time,
doesn't work anymore.
NEED HELP..
Private Sub CommandButton1_Click()
ans = MsgBox("Do you want to print faxes?", vbYesNo)
If ans = vbNo Then
Exit Sub
End If
Dim col As Integer
Dim row As Integer
Dim counter As Integer
Dim I As Integer


col = 2
row = 2
counter = 1

For row = row To 20
If Sheet8.Cells(row, counter) = "" Then
Exit Sub
Else
Sheet1.Cells(3, 7) = Sheet8.Cells(row, counter)
counter = counter + 1
Sheet1.Cells(5, 3) = Sheet8.Cells(row, counter)
counter = counter + 1
Sheet1.Cells(5, 6) = Sheet8.Cells(row, counter)
counter = counter + 1
Sheet1.Cells(5, 9) = Sheet8.Cells(row, counter)
counter = counter + 1
Sheet1.Cells(5, 12) = Sheet8.Cells(row, counter)
counter = counter + 1
counter = 1
Sheet1.PrintOut
Sheet8.Cells(row, 5) = "PRINTED"



For I = I To 300
Next I
I = 0


End If
Next row

End Sub


Private Sub CommandButton2_Click()
Dim row1 As Integer
Dim count As Integer
row1 = 2
count = 1
For row1 = row1 To 30
For count = count To 5
Sheet8.Cells(row1, count) = ""
Next count
count = 1
Next row1
End Sub


Tom Ogilvy

program
 
Clicking Commandbutton2 clears all the values out of Sheet8, rows 2 to 30

the first test in CommandButton1 is

If Sheet8.Cells(row, counter) = "" Then
Exit Sub
Else

so it quites on the first empty cell in Sheet8 in A2:A20

Possible that you have empty cells in column 1 of sheet8?

--
Regards,
Tom Ogilvy


"Fernando Duran" wrote:

I have an small program with a bug in the second pass to print a spread
sheet, it does the fisrt time without no problems, but the second time,
doesn't work anymore.
NEED HELP..
Private Sub CommandButton1_Click()
ans = MsgBox("Do you want to print faxes?", vbYesNo)
If ans = vbNo Then
Exit Sub
End If
Dim col As Integer
Dim row As Integer
Dim counter As Integer
Dim I As Integer


col = 2
row = 2
counter = 1

For row = row To 20
If Sheet8.Cells(row, counter) = "" Then
Exit Sub
Else
Sheet1.Cells(3, 7) = Sheet8.Cells(row, counter)
counter = counter + 1
Sheet1.Cells(5, 3) = Sheet8.Cells(row, counter)
counter = counter + 1
Sheet1.Cells(5, 6) = Sheet8.Cells(row, counter)
counter = counter + 1
Sheet1.Cells(5, 9) = Sheet8.Cells(row, counter)
counter = counter + 1
Sheet1.Cells(5, 12) = Sheet8.Cells(row, counter)
counter = counter + 1
counter = 1
Sheet1.PrintOut
Sheet8.Cells(row, 5) = "PRINTED"



For I = I To 300
Next I
I = 0


End If
Next row

End Sub


Private Sub CommandButton2_Click()
Dim row1 As Integer
Dim count As Integer
row1 = 2
count = 1
For row1 = row1 To 30
For count = count To 5
Sheet8.Cells(row1, count) = ""
Next count
count = 1
Next row1
End Sub




All times are GMT +1. The time now is 04:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com