Sub CustomSheetMaker()
Dim x As Integer
Dim y As Long
Dim shtName
x = Application.InputBox("Please select a number of columns", "Number of Columns")
If x = False Then Exit Sub
If x > 256 Or x < 5 Then
MsgBox "You cannot have more than 256 columns" & vbCr _
& "or less than " & x & " columns." & vbCr & _
"Please start again.", vbCritical, "Error"
Exit Sub
End If
y = Application.InputBox("Please select a number of rows", "Number of rows")
If y = False Then Exit Sub
If y > 65536 Or y < 5 Then
MsgBox "You cannot have more than 65536 rows" & vbCr _
& "or less than " & y & " rows." & vbCr & _
"Please start again.", vbCritical, "Error"
Exit Sub
End If
shtName = Application.InputBox("Type a name for the new sheet", "New sheet name")
If shtName = False Then Exit Sub
If Len(shtName) < 3 Then
MsgBox "You did not enter a valid sheet name." & vbCr & _
"Please use 3 or more characters." & vbCr & _
"Please start again.", vbCritical, "Error"
Exit Sub
End If
ActiveWorkbook.Sheets.Add after:=Worksheets(Worksheets.Count)
With ActiveSheet
.Name = shtName
.Range(Cells(y + 1, 256), Cells(65536, x + 1)).EntireColumn.Hidden = True
.Range(Cells(65536, x + 1), Cells(y + 1, 256)).EntireRow.Hidden = True
End With
End Sub
|