Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I am trying to get my brain around how to take the information from an input box and use that data to rename the excel sheet. For example, I want to prompt for a week number and then rename the sheet to be that week number. I then want to use the Week number for other things. I am still fairly new to excel programming and just can't figure it out at the moment. Any help would be great. Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub GetandUseInput()
Dim myInput as String 'declare variable myInput = InputBox("Input your week number", "InputBox Title") If myInput = "" then 'Cancel was clicked Exit Sub Else ActiveSheet.Name = "Week" & myInput 'some other stuff using myInput End if End Sub This sub first declares a string variable called myInput. Inputboxes take strings (text) as input. The value of myInput is then equal to the value in the InputBox. The active worksheet is then given the name "Week" & myInput. The "&" operand is used to connect strings, so if 3 was entered in the inputbox you would see the Activesheet being renamed as "Week3". You can also use Application.InputBox This gives you a slightly different kind of inputbox which allows you to specify the type of the input and you will also need Dim myInput as Variant the input can now be a number or string or.. See the Help. regrads Paul On Feb 11, 12:42*pm, sus1e wrote: Hi, I am trying to get my brain around how to take the information from an input box and use that data to rename the excel sheet. For example, I want to prompt for a week number and then rename the sheet to be that week number. I then want to use the Week number for other things. I am still fairly new to excel programming and just can't figure it out at the moment. Any help would be great. Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Wonderful, Thanks.
I was half way there and knew that as soon as someone with brains came along it would be sorted for me. Thanks again! " wrote: Sub GetandUseInput() Dim myInput as String 'declare variable myInput = InputBox("Input your week number", "InputBox Title") If myInput = "" then 'Cancel was clicked Exit Sub Else ActiveSheet.Name = "Week" & myInput 'some other stuff using myInput End if End Sub This sub first declares a string variable called myInput. Inputboxes take strings (text) as input. The value of myInput is then equal to the value in the InputBox. The active worksheet is then given the name "Week" & myInput. The "&" operand is used to connect strings, so if 3 was entered in the inputbox you would see the Activesheet being renamed as "Week3". You can also use Application.InputBox This gives you a slightly different kind of inputbox which allows you to specify the type of the input and you will also need Dim myInput as Variant the input can now be a number or string or.. See the Help. regrads Paul On Feb 11, 12:42 pm, sus1e wrote: Hi, I am trying to get my brain around how to take the information from an input box and use that data to rename the excel sheet. For example, I want to prompt for a week number and then rename the sheet to be that week number. I then want to use the Week number for other things. I am still fairly new to excel programming and just can't figure it out at the moment. Any help would be great. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
input vs. result | Excel Discussion (Misc queries) | |||
Advanced formula - Return result & Show Cell Reference of result | Excel Worksheet Functions | |||
Importing result from Access query to Excel but the result only c. | Excel Discussion (Misc queries) | |||
vlookup based on random result returns incorrect result | Excel Worksheet Functions | |||
Using result of user input? | Excel Programming |