0

I have tried to get a value Range address value in to a variable.

searchWrd = InputBox("Please enter the column name of first word/token's", "Search String", "J1")

I need to verify the variable searchWrd contains a valid address or not. Also what should be the data type for the variable searchWrd

1
  • error trap, setting it as a range. "Search String" :) Commented Apr 28, 2017 at 8:06

2 Answers 2

1

I'd go with

searchWrd = Application.InputBox("lease enter the column name of first word/token's", "Search String", ,,,,,8)

For more information read this: https://msdn.microsoft.com/en-us/library/office/ff839468.aspx

Basically, the 8 at the end sets the input type to be a range. Note, that this will also allow you to immediately Dim searchWrd as Range.

Sign up to request clarification or add additional context in comments.

1 Comment

I am using excel 2016. But the type argument is not there for inputbox method. The last argument available is context. Hence the code gives error
0

You could try to verify the Text you get from the Inputbox by using a normal If-Then-construct. To get the correct data type we Need to know what should be possbible to type into the Inputbox. Normally i would try to get the Row/Column Number of the Row/Column the Search string is located at. Or, much better, to ask for the string it self and write the code to look up where it is located. So i only Need to check for spelling Errors and give a message that the string isn't found. It's better then asking for a range i think.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.