ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inputbox's and Prompt value (https://www.excelbanter.com/excel-programming/339767-inputboxs-prompt-value.html)

Kryer

Inputbox's and Prompt value
 
I want to create an inputbox with the prompt values being listed from cell
values on a worksheet. So say I have range("a2:a10") filled with values that
I would like to display as the prompt of the inputbox. Is this possible to do?

Norman Jones

Inputbox's and Prompt value
 
Hi Kryer,

It is not clear what you want to achieve, but to use a cell value as the
prompt for an input box, try something like:

Public Sub nTest()
Dim res As Variant

res = InputBox(prompt:=ActiveSheet.Range("A2").Value)

End Sub

Depending on what you want to do, the prompt could represent a concatenation
of cell values.

Public Sub nTest2()
Dim res As Variant
Dim sStr As String

With ActiveSheet
sStr = .Range("A1").Value & " " & .Range("A2").Value _
& " " & .Range("A3").Value '...
End With

res = InputBox(prompt:=sStr)

End Sub

Alternatively, input boxes could be shown with successive cell values as the
prompt, by looping through the cells:

Public Sub nTest3()
Dim res As Variant
Dim rng As Range
Dim rCell As Range

Set rng = ActiveSheet.Range("A2:A10")

For Each rCell In rng.Cells
res = InputBox(prompt:=rCell.Value)
Next rCell

End Sub

If the above does not help, post back with more detail of your requirements.

---
Regards,
Norman



"Kryer" wrote in message
...
I want to create an inputbox with the prompt values being listed from cell
values on a worksheet. So say I have range("a2:a10") filled with values
that
I would like to display as the prompt of the inputbox. Is this possible to
do?




Kryer

Inputbox's and Prompt value
 
I am trying to do something like that of the concatenation style but saying
to do it with all cells from A2:A30 with out having to enter in each of the
range values by hand like with your example. Is this going to be the only way
I can do this. What I am trying to do in the end is add a new name without
duplication of it in the list. Do you have another idea about this.

"Norman Jones" wrote:

Hi Kryer,

It is not clear what you want to achieve, but to use a cell value as the
prompt for an input box, try something like:

Public Sub nTest()
Dim res As Variant

res = InputBox(prompt:=ActiveSheet.Range("A2").Value)

End Sub

Depending on what you want to do, the prompt could represent a concatenation
of cell values.

Public Sub nTest2()
Dim res As Variant
Dim sStr As String

With ActiveSheet
sStr = .Range("A1").Value & " " & .Range("A2").Value _
& " " & .Range("A3").Value '...
End With

res = InputBox(prompt:=sStr)

End Sub

Alternatively, input boxes could be shown with successive cell values as the
prompt, by looping through the cells:

Public Sub nTest3()
Dim res As Variant
Dim rng As Range
Dim rCell As Range

Set rng = ActiveSheet.Range("A2:A10")

For Each rCell In rng.Cells
res = InputBox(prompt:=rCell.Value)
Next rCell

End Sub

If the above does not help, post back with more detail of your requirements.

---
Regards,
Norman



"Kryer" wrote in message
...
I want to create an inputbox with the prompt values being listed from cell
values on a worksheet. So say I have range("a2:a10") filled with values
that
I would like to display as the prompt of the inputbox. Is this possible to
do?





Tom Ogilvy

Inputbox's and Prompt value
 
If you have xl2000 or later

Sub AA()
Dim v as Variant, a as String
Dim res as String
v = Application.Transpose(Range("A2:A10"))
a = Join(v,chr(10))
res = InputBox(a)
End Sub

If you just want to concatenate the values, replace Chr(10) with " " or ""

--
Regards,
Tom Ogilvy

"Kryer" wrote in message
...
I want to create an inputbox with the prompt values being listed from cell
values on a worksheet. So say I have range("a2:a10") filled with values

that
I would like to display as the prompt of the inputbox. Is this possible to

do?



Kryer

Inputbox's and Prompt value
 
Thanks this is what i was looking for

"Tom Ogilvy" wrote:

If you have xl2000 or later

Sub AA()
Dim v as Variant, a as String
Dim res as String
v = Application.Transpose(Range("A2:A10"))
a = Join(v,chr(10))
res = InputBox(a)
End Sub

If you just want to concatenate the values, replace Chr(10) with " " or ""

--
Regards,
Tom Ogilvy

"Kryer" wrote in message
...
I want to create an inputbox with the prompt values being listed from cell
values on a worksheet. So say I have range("a2:a10") filled with values

that
I would like to display as the prompt of the inputbox. Is this possible to

do?





All times are GMT +1. The time now is 05:28 PM.

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