View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Problem with IF Statements Within VBA Code

Sub PrintProrateWorksheet() 'Print copies of Standard Prorate Sheets'

If Sheets("Data_Entry_Sheet").[H47] = "X" Then

shtSProrate.Activate
With shtSProrate
..Unprotect "led52not"
..Shapes("Text Box 1").Select
Selection.Characters.Text = "P"
..Shapes("Text Box 2").Select
Selection.Characters.Text = ""
..Shapes("Text Box 3").Select
Selection.Characters.Text = ""
..Shapes("Text Box 4").Select
Selection.Characters.Text = ""
..PrintOut
..Shapes("Text Box 1").Select
Selection.Characters.Text = ""
..Shapes("Text Box 2").Select
Selection.Characters.Text = "P"
..PrintOut
..Shapes("Text Box 2").Select
Selection.Characters.Text = ""
..Shapes("Text Box 3").Select
Selection.Characters.Text = "P"
..PrintOut
..Shapes("Text Box 3").Select
Selection.Characters.Text = ""
..Shapes("Text Box 4").Select
Selection.Characters.Text = "P"
..PrintOut
..Shapes("Text Box 4").Select
Selection.Characters.Text = ""
..Range("A12").Select
Sheet2.Select
[a1].Select
..Protect "led52not"
End With
Exit Sub
End If

If Sheets("Data_Entry_Sheet").[H49] = "X" Then

shtSProrate.Activate
With shtSProrate
..Unprotect "led52not"
..Shapes("Text Box 1").Select
Selection.Characters.Text = ""
..Shapes("Text Box 2").Select
Selection.Characters.Text = "P"
..PrintOut
..Shapes("Text Box 2").Select
Selection.Characters.Text = ""
..Shapes("Text Box 3").Select
Selection.Characters.Text = "P"
..PrintOut
..Shapes("Text Box 3").Select
Selection.Characters.Text = ""
..Shapes("Text Box 4").Select
Selection.Characters.Text = "P"
..PrintOut
..Shapes("Text Box 4").Select
Selection.Characters.Text = ""
..Range("A12").Select
Sheet2.Select

End With
End If

End Sub

--
Regards,
Tom Ogilvy

"golf4" wrote in message
om...
AGAIN.... Midnight here and I can't seem to wrap my brain around the
problem I'm having with my code. I've posted it below and this is what
I'm trying to do. The code is designed to print out worksheets that
will calculate the prorated amount of rent while populating check
boxes. It worked fine until I tried adding the IF statements: IF H47
="X", then four copies of the worksheet will print out; IF H49 ="X",
then it should print out the three copies. The different cell
references represent two different programs. The problem is that my
code is now not working (with the two different IF statements). I have
a feeling that it has to do with the transition strip:

Exit Sub
Else
End If

...... but I can't seem to figure it out. Any help would be
fantastic!!!


Sub PrintProrateWorksheet() 'Print copies of Standard Prorate Sheets'

If Sheets("Data_Entry_Sheet").[H47] = "X" Then

shtSProrate.Activate
With shtSProrate
.Unprotect "led52not"
.Shapes("Text Box 1").Select
Selection.Characters.Text = "P"
.Shapes("Text Box 2").Select
Selection.Characters.Text = ""
.Shapes("Text Box 3").Select
Selection.Characters.Text = ""
.Shapes("Text Box 4").Select
Selection.Characters.Text = ""
.PrintOut
.Shapes("Text Box 1").Select
Selection.Characters.Text = ""
.Shapes("Text Box 2").Select
Selection.Characters.Text = "P"
.PrintOut
.Shapes("Text Box 2").Select
Selection.Characters.Text = ""
.Shapes("Text Box 3").Select
Selection.Characters.Text = "P"
.PrintOut
.Shapes("Text Box 3").Select
Selection.Characters.Text = ""
.Shapes("Text Box 4").Select
Selection.Characters.Text = "P"
.PrintOut
.Shapes("Text Box 4").Select
Selection.Characters.Text = ""
.Range("A12").Select
Sheet2.Select
[a1].Select
.Protect "led52not"

Exit Sub
Else
End If

If Sheets("Data_Entry_Sheet").[H49] = "X" Then

shtSProrate.Activate
With shtSProrate
.Unprotect "led52not"
.Shapes("Text Box 1").Select
Selection.Characters.Text = ""
.Shapes("Text Box 2").Select
Selection.Characters.Text = "P"
.PrintOut
.Shapes("Text Box 2").Select
Selection.Characters.Text = ""
.Shapes("Text Box 3").Select
Selection.Characters.Text = "P"
.PrintOut
.Shapes("Text Box 3").Select
Selection.Characters.Text = ""
.Shapes("Text Box 4").Select
Selection.Characters.Text = "P"
.PrintOut
.Shapes("Text Box 4").Select
Selection.Characters.Text = ""
.Range("A12").Select
Sheet2.Select

End With
End If
End With
End If
End Sub


Thanks so much,

Golf