ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Creating an custom input box (https://www.excelbanter.com/excel-worksheet-functions/18038-creating-custom-input-box.html)

[email protected]

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


Jason Morin

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

.



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

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