Multiple inputs from "Input Box"

M

Megadrone

I want to get multiple entries to paste to another sheet. I have the
following input box working to request one entry. Can anyone tell me how to
use the same box for multiple requests to append to "Sheet1"? Also, if entry
is wrong, I need to just return them back to the input box.
Please forgive any mistakes, I just had brain surgery...Really!!

Market = Application.InputBox("Enter your market")

Sheets("Daily_info").Select
Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=18, Criteria1:=Market, Operator:=xlAnd
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Sheet1").Select
ActiveSheet.Paste
 
J

JP

Here's how I do it:

Dim ReportTime As String
Dim strDate As String
Dim strTime As String

ReportTime = InputBox("Enter date and time (24-hour time format):" &
vbCr & vbCr & "Ex: 8/1/2008 18:30 (for 6:30 pm).")

strDate = Left$(ReportTime, WorksheetFunction.Find(" ", ReportTime) -
1)
strTime = Right$(ReportTime, Len(ReportTime) -
WorksheetFunction.Find(" ", ReportTime))



After you run this, the two separate elements from the Inputbox are
stored in two string variables.

HTH,
JP
 
M

Megadrone

I do believe I was misunderstood, I want them to enter an item in the input
box (it is them pasted to Sheet1) then I want them to be able to return to
the input box and enter another item and so on. when they are finished I
want some way to end the input function.
 
J

JP

Inputbox returns "" when Cancel is pressed. Wrap the Inputbox in a Do
Loop that checks if the returned string is "", then you know the user
is finished. Otherwise it keeps looping and asking for more input. You
can also do simply data validation on the inputted string, for example
IsDate() to make sure the user entered a valid date. Anything more
complicated than that, an Inputbox is inadequate; you'd want to use a
userform.

Dim ReportTime As String
Dim strDate As String
Dim strTime As String

Do Until ReportTime = ""

ReportTime = InputBox("Enter date and time (24-hour time format):" &
vbCr & vbCr & "Ex: 8/1/2008 18:30 (for 6:30 pm).")

strDate = Left$(ReportTime, WorksheetFunction.Find(" ", ReportTime) -
1)
strTime = Right$(ReportTime, Len(ReportTime) -
WorksheetFunction.Find(" ", ReportTime))

Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

help with input box 1
Macro - Whats wrong? 4
Macro to copy value in field and insert it into filter 2
BwiSwy Help Please 1
Macro1 2
Different Results from the Same Macro 2
issue copying data 2
Help me4 2

Top