thomas.szwed
09-05-2008, 02:21 AM
Hi there,
I have the following statement
Sub FormatAndPreview()
Dim sSheetName As String
sSheetName = Application.VLookup(Range("K10").Value, Range("F117:G124"), 2, False)
With Sheets(sSheetName)
.Rows.AutoFit
.PrintPreview
End With
End Sub
This first part of this fills a sSheetName from Cell K10 in my worksheet. This code runs when a button is clicked. However my users can still select this button when there is no value entered in cell K10. This results in a runtime error, which i certainly dont want to be showing my users!! What code can i add to prevent this code running unless there is a value in K10?
Many Thanks for any help.
I have the following statement
Sub FormatAndPreview()
Dim sSheetName As String
sSheetName = Application.VLookup(Range("K10").Value, Range("F117:G124"), 2, False)
With Sheets(sSheetName)
.Rows.AutoFit
.PrintPreview
End With
End Sub
This first part of this fills a sSheetName from Cell K10 in my worksheet. This code runs when a button is clicked. However my users can still select this button when there is no value entered in cell K10. This results in a runtime error, which i certainly dont want to be showing my users!! What code can i add to prevent this code running unless there is a value in K10?
Many Thanks for any help.