ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Returning a cell address in a msgbox, by selection via inputbox Ty (https://www.excelbanter.com/excel-discussion-misc-queries/227011-returning-cell-address-msgbox-selection-via-inputbox-ty.html)

FARAZ QURESHI

Returning a cell address in a msgbox, by selection via inputbox Ty
 
I want to use a Type:=8 Inputbox allowing the user to select a cell and then
later on using the address of the range/cell selected so as a string.

For example:

Sub test()
Dim rng3 As String
rng3 = Application.InputBox(prompt:="Select rng1", Type:=8)
MsgBox (rng3)
End Sub

returns the value that is inside the cell selected instead of the actual
address of the cell. In other words upon first prompt if the user selects the
cell A1, the second prompt displays the contents of A1 but not "A1".

Thanx in advance for all your help.

Gary''s Student

Returning a cell address in a msgbox, by selection via inputbox Ty
 
You were very close:

Sub GetAddy()
Dim rng As Range
Dim st As String
Set rng = Application.InputBox(prompt:="select a range", Type:=8)
MsgBox (rng.Address)
End Sub


Note that the User has the option of either typing in range address in the
inputbox or selecting it with the mouse instead!
--
Gary''s Student - gsnu200844


"FARAZ QURESHI" wrote:

I want to use a Type:=8 Inputbox allowing the user to select a cell and then
later on using the address of the range/cell selected so as a string.

For example:

Sub test()
Dim rng3 As String
rng3 = Application.InputBox(prompt:="Select rng1", Type:=8)
MsgBox (rng3)
End Sub

returns the value that is inside the cell selected instead of the actual
address of the cell. In other words upon first prompt if the user selects the
cell A1, the second prompt displays the contents of A1 but not "A1".

Thanx in advance for all your help.


FARAZ QURESHI

Returning a cell address in a msgbox, by selection via inputbo
 
Thanx Gary!

A genius like u couldn't be a student!. However, why have u declared the
variable "st"?

"Gary''s Student" wrote:

You were very close:

Sub GetAddy()
Dim rng As Range
Dim st As String
Set rng = Application.InputBox(prompt:="select a range", Type:=8)
MsgBox (rng.Address)
End Sub


Note that the User has the option of either typing in range address in the
inputbox or selecting it with the mouse instead!
--
Gary''s Student - gsnu200844


"FARAZ QURESHI" wrote:

I want to use a Type:=8 Inputbox allowing the user to select a cell and then
later on using the address of the range/cell selected so as a string.

For example:

Sub test()
Dim rng3 As String
rng3 = Application.InputBox(prompt:="Select rng1", Type:=8)
MsgBox (rng3)
End Sub

returns the value that is inside the cell selected instead of the actual
address of the cell. In other words upon first prompt if the user selects the
cell A1, the second prompt displays the contents of A1 but not "A1".

Thanx in advance for all your help.


Gary''s Student

Returning a cell address in a msgbox, by selection via inputbo
 
I was going to:

st=rng.Address
MsgBox(st)

but it is not necessary unless you need to "remember" the address.
--
Gary''s Student - gsnu200844


"FARAZ QURESHI" wrote:

Thanx Gary!

A genius like u couldn't be a student!. However, why have u declared the
variable "st"?

"Gary''s Student" wrote:

You were very close:

Sub GetAddy()
Dim rng As Range
Dim st As String
Set rng = Application.InputBox(prompt:="select a range", Type:=8)
MsgBox (rng.Address)
End Sub


Note that the User has the option of either typing in range address in the
inputbox or selecting it with the mouse instead!
--
Gary''s Student - gsnu200844


"FARAZ QURESHI" wrote:

I want to use a Type:=8 Inputbox allowing the user to select a cell and then
later on using the address of the range/cell selected so as a string.

For example:

Sub test()
Dim rng3 As String
rng3 = Application.InputBox(prompt:="Select rng1", Type:=8)
MsgBox (rng3)
End Sub

returns the value that is inside the cell selected instead of the actual
address of the cell. In other words upon first prompt if the user selects the
cell A1, the second prompt displays the contents of A1 but not "A1".

Thanx in advance for all your help.



All times are GMT +1. The time now is 08:20 PM.

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