+ Reply to Thread
Results 1 to 2 of 2

Creating an custom input box

  1. #1

    Creating an custom input box

    I was wondering if someone could help me here.
    Im attempting to create an input box that will ask the user for a
    number and in turn use this number to identify a sheet , then take
    another input from the user and place it in a specific cell in the
    sheet specified in the first step.

    1.i will create an excel file with 31 sheets
    2.when user runs file he will get a popup box asking for sheet wanted
    3.the user will input a number between 1-31
    4.a new box will open asking for data (lets assume a number)
    5.Excel will place this value in Sheet(x) and a preassigned cell


    Im very new to VBA so i apologise for the newbie post

    any help on this owuld be appreciated. Thank you


  2. #2
    Jason Morin
    Guest

    Re: Creating an custom input box

    This should get you started. Press ALT+F11, double-click
    on the ThisWorkbook module (if you don't see it, go to
    View > Project Explorer), and paste in the code below.
    Press ALT+Q and save the workbook. Close and re-open.

    Option Explicit
    Sub Workbook_Open()
    Dim SheetNo As Long
    Dim sPrompt1 As String
    Dim sPrompt2 As String
    Dim dValuetoCell As Double
    Dim rTargetCell As Range

    Set rTargetCell = Range("A1")
    sPrompt1 = "Enter a number, 1-31:"
    sPrompt2 = "Enter value to " & _
    "insert into cell " & _
    rTargetCell.Address(False, False) & ":"

    SheetNo = Application. _
    InputBox(prompt:=sPrompt1, Type:=1)

    Worksheets(SheetNo).Select

    dValuetoCell = Application. _
    InputBox(prompt:=sPrompt2, Type:=1)

    ActiveSheet.Cells(rTargetCell.Row, _
    rTargetCell.Column).Value = dValuetoCell

    End Sub

    ---
    Not much error-checking. If the user types in "32" on the
    first Inputbox, the code will error.

    HTH
    Jason
    Atlanta, GA

    >-----Original Message-----
    >I was wondering if someone could help me here.
    >Im attempting to create an input box that will ask the

    user for a
    >number and in turn use this number to identify a sheet ,

    then take
    >another input from the user and place it in a specific

    cell in the
    >sheet specified in the first step.
    >
    >1.i will create an excel file with 31 sheets
    >2.when user runs file he will get a popup box asking for

    sheet wanted
    >3.the user will input a number between 1-31
    >4.a new box will open asking for data (lets assume a

    number)
    >5.Excel will place this value in Sheet(x) and a

    preassigned cell
    >
    >
    >Im very new to VBA so i apologise for the newbie post
    >
    >any help on this owuld be appreciated. Thank you
    >
    >.
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1