ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Sub procedure in Macros (https://www.excelbanter.com/excel-worksheet-functions/119328-sub-procedure-macros.html)

Lady Excel

Sub procedure in Macros
 
I am trying to insert a 3rd sub procedure to pick a certain worksheet when a
variable is entered in a input box. I can get it to pick a column but it
won't pick a sheet. Does anyone know what I am doing wrong?
Here is what I have done.
Public Sub Show_Histogram()
'
' Histogram Macro
' This macro displays the contents of the Histogram worksheet.
'

'

Dim Source
Source = InputBox("Enter a filler (A-E)", "Specify Bottle Filler")
Source = UCase(Source)
If Source = "A" Or Source = "B" Or Source = "C" Or Source = "D" Or Source =
"E" Then
ActiveWorkbook.Names.Add Name:="Histogram", RefersToR1C1:="=Histogram" &
Source
ElseIf Source < "" Then
MsgBox "Please enter a letter from A to E", vbCritical, "Invalid Filler"
End If
End Sub

Any help would be appreciated.

Don Guillett

Sub procedure in Macros
 
a simple idea for you

Sub picksheet()
Sheets(InputBox("Sheet?")).Select
Columns(InputBox("col ltr")).Select
End Sub

--
Don Guillett
SalesAid Software

"Lady Excel" <Lady
wrote in message
...
I am trying to insert a 3rd sub procedure to pick a certain worksheet when
a
variable is entered in a input box. I can get it to pick a column but it
won't pick a sheet. Does anyone know what I am doing wrong?
Here is what I have done.
Public Sub Show_Histogram()
'
' Histogram Macro
' This macro displays the contents of the Histogram worksheet.
'

'

Dim Source
Source = InputBox("Enter a filler (A-E)", "Specify Bottle Filler")
Source = UCase(Source)
If Source = "A" Or Source = "B" Or Source = "C" Or Source = "D" Or Source
=
"E" Then
ActiveWorkbook.Names.Add Name:="Histogram", RefersToR1C1:="=Histogram"
&
Source
ElseIf Source < "" Then
MsgBox "Please enter a letter from A to E", vbCritical, "Invalid
Filler"
End If
End Sub

Any help would be appreciated.





All times are GMT +1. The time now is 02:11 AM.

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