Returnera en cell adress från inputbox

Loranga

New Member
Joined
Jan 30, 2007
Messages
36
Hej,

Jag har ett problem som jag ska försöka förklara så gott det går...
Jag försöker att returnera adressen för en cell eller range som användaren väljer genom att klicka på en knapp (btnRange) och skulle vilja att den adressen skickas till txtInput.

Som det är nu så fungerar programmet bra om jag tex skriver B2+100 för hand i inputboxen men vad jag skulle vilja uppnå är att jag vill kunna klicka på range välja cellen B2 och då ska det stå B2 i inputboxen och inte själva cellvärdet i B2.






Code:
Private Sub btnRange_Click()

On Error Resume Next
 
Dim InputCells As Range

'Type:=0 A formula
'Type:=1 A number
'Type:=2 Text (a string)
'Type:=4 A logical value (True or False)
'Type:=8 A cell reference, as a Range object
'Type:=16 An error value, such as #N/A
'Type:=64 An array of values

Set InputCells = _
Application.InputBox(prompt:="Select cell/range", _
Title:="Select cell/range", Type:=8)

txtInput = InputCells

Call btnCalc_Click

End Sub

Private Sub btnCalc_Click()

On Error Resume Next
txtOutput.Text = Evaluate(txtInput.Text)

End Sub
Private Sub btnCopy_Click()
Dim MyDataObj As New DataObject
MyDataObj.SetText txtOutput.Value
MyDataObj.PutInClipboard
MyDataObj.GetFromClipboard
End Sub
Private Sub btnClose_Click()
Unload Me
End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,215,105
Messages
6,123,114
Members
449,096
Latest member
provoking

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top