Solved: input box data to run macro

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

mrl

Thread Starter
Joined
Aug 12, 2007
Messages
342
Hi, Happy New Year
I'm having a mind freeze.
I'm trying to have an input box come up asking "what Month?" and then going to that month. I range named each month. I can't seem to get started.


Mike :confused:
 

mrl

Thread Starter
Joined
Aug 12, 2007
Messages
342
Hi Rollin

Yes Excel 2007. I Want to have a box come up after I click on a macro button and ask "what Month?", Then, depending on the input (January, February, March, etc.) I want go to that month. I ranged name each month: This is what I have so far:
HTML:
Sub selectmonth()
Dim strName As String
    strName = InputBox("                       What Month? ) 
    If strName = vbNullString Then
    Exit Sub
    Else
End sub
I figured to have a macro for each range name (month) I'm still learning about macros and wanted to use something I already know.

Mike
 

Attachments

Joined
Sep 4, 2003
Messages
4,912
Here is the modified code. Using an inputbox is bad practice in my opinion because there is too much opportunity for the user to enter data into the inputbox that is not valid or spelled correctly. You are better off creating a list of the allowed months in an unused range in your workbook and then use data validation in a cell to force the user to select one of the allowable month values. The macro code could then be fired using an embedded button located somewhere on your worksheet. Another option would be to create your own form and use a listbox or combobox to select the month.

Code:
Sub SelectMonth()

Dim strName As String

strName = InputBox("Enter Month")

If strName = vbNullString Then
  Exit Sub
Else

  Select Case strName

     Case "January"
        Application.Goto Reference:="January"
     Case "February"
       Application.Goto Reference:="February"
     Case Else
     MsgBox ("MONTH NOT FOUND")
     Exit Sub

End Select

Rollin
 

mrl

Thread Starter
Joined
Aug 12, 2007
Messages
342
Hi Rollin, Thanks for the help. I wanted to use something that is already in my macro's that I could build on. A great way to learn ! I'm going to look at "data validation" and try to do the same thing that way. I like the idea of "mistake proof"
Have a Happy New year


Mike
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top