MHadden
Programmer
- May 13, 2001
- 105
A friend asked me to help him streamline the following code. I tried Select Case, but couldn't get it to work. The code, as it is, works - he was just hoping to shorten it. I am posting only a small amount here, but it follows this same pattern for several cells.
Any help is appreciated. If you need the full code, I can include it, but it's rather repetitive.
Thanks - in - advance
- Michael
MichaelHadden@yahoo.com
If you give someone a fish, you have given them a meal. If you teach someone to fish, you have given them MANY meals!
Code:
Private Sub PrintDispatchForms_Click()
Sheets("Program Information").Select
If (Cells(2, "B") <> "") Then
DriverName = Cells(2, "B")
DriverLocation = Cells(2, "A")
Sheets("Dispatch Driver Log").Select
Cells(1, "C") = DriverName
Cells(3, "C") = DriverLocation
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
Sheets("Program Information").Select
If (Cells(3, "B") <> "") Then
DriverName = Cells(3, "B")
DriverLocation = Cells(3, "A")
Sheets("Dispatch Driver Log").Select
Cells(1, "C") = DriverName
Cells(3, "C") = DriverLocation
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
Sheets("Program Information").Select
If (Cells(4, "B") <> "") Then
DriverName = Cells(4, "B")
DriverLocation = Cells(4, "A")
Sheets("Dispatch Driver Log").Select
Cells(1, "C") = DriverName
Cells(3, "C") = DriverLocation
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
Any help is appreciated. If you need the full code, I can include it, but it's rather repetitive.
Thanks - in - advance
- Michael
MichaelHadden@yahoo.com
If you give someone a fish, you have given them a meal. If you teach someone to fish, you have given them MANY meals!