0

I've got a Do-While loop in VBA asking the user for their company UserID. This is used to find a folder in their personal folder, doesn't really matter that much.

I'm using an Input Box as I don't know how else I would do this:

Do
    filepath2 = Application.InputBox("Enter your User FDIC", "UFDIC")
    If filepath2 = False Then Exit Sub
    filepath3 = "C:\Users\" & filepath2 & "\Desktop\NSC\"
    Dir (filepath3)
Loop While Not Dir(filepath3) > ""

So basically, this will ask the user for UserID, if the user selects the button "Cancel", it will exit the sub. If not, it will take the UserID and make sure it exists. I'm getting a Type Mismatch error when it comes to the line

If filepath2 = False Then Exit Sub

due to it expecting a Boolean value, I think.

Should I be using something other than an Input Box?

If not, how do I type check?

pnuts
  • 58,317
  • 11
  • 87
  • 139
Tawm
  • 535
  • 3
  • 12
  • 25
  • Could not use Environ("username") to return the right username? (as a default value perhaps) – Tom Nov 11 '15 at 14:59

1 Answers1

0

I figured it out.

Simply have to change

If filepath2 = False Then Exit Sub

to

If filepath2 = "False" Then Exit Sub

Just changing to a String.

Tawm
  • 535
  • 3
  • 12
  • 25
  • 1
    Not the usual solution. http://stackoverflow.com/questions/16061562/trouble-with-inputboxes & http://stackoverflow.com/questions/26264814/how-to-detect-if-user-select-cancel-inputbox-vba-excel – niton Nov 11 '15 at 15:41