1

Hey guys I have a a coding issue in vba.

 Dim table As String
 Set table = InputBox("Text","Title","Default")

I then get the message:

Error while compiling Object required

The phrase

    table =

Is marked blue

Why do I get the error while compiling?

0

2 Answers 2

3

If InputBox does return a String you have to remove the Set (which is only needed for objects):

Dim table As String
table = InputBox("Text","Title","Default")
Sign up to request clarification or add additional context in comments.

Comments

0

The Set statement is used with variables that are an Object type.

Per the VBE Glossary for object-type;

A type of object exposed by an application through Automation, for example, Application, File, Range, and Sheet. Use the Object Browser or refer to the application's documentation for a complete listing of available objects.

A String is not an object data type so you don't need to include the Set keyword.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.