Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Using the result of an input box

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Using the result of an input box

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Using the result of an input box

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
input vs. result amy howell Excel Discussion (Misc queries) 4 March 18th 08 01:35 PM
Advanced formula - Return result & Show Cell Reference of result Irv Excel Worksheet Functions 7 May 6th 06 03:36 AM
Importing result from Access query to Excel but the result only c. Edwin Excel Discussion (Misc queries) 0 March 16th 06 01:36 AM
vlookup based on random result returns incorrect result rickat Excel Worksheet Functions 1 December 6th 05 01:16 PM
Using result of user input? PaulSinki[_4_] Excel Programming 2 December 15th 03 11:00 AM


All times are GMT +1. The time now is 10:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"