Inputboxes

Dummy Excel

Well-known Member
Joined
Sep 21, 2005
Messages
1,004
Office Version
  1. 2019
  2. 2010
  3. 2007
Platform
  1. Windows
Hi All,
I have an inputbox
Code:
customer = UCase(InputBox("Enter Customer Name", "Customer", "XXX X"))

The problem I have is that some users may seperate the 2 words for the customer name, as later down the code I have a IF statement saying if the customer is A do this, if the B do this and so on.

My problem is, if the user seperates the customer, the IF statement wont find a match.
my code for the IF statement is:
Code:
    If customer = "XXXXX" Then
        Application.DisplayAlerts = False
        ActiveWorkbook.SaveAs Filename:="\\share\XXXXX\" & business & " - " & dept & ".xls"
        Application.DisplayAlerts = True
    Else
    If customer = "XXXXXX" Then
        Application.DisplayAlerts = False
        ActiveWorkbook.SaveAs Filename"\\share\XXXXXX\" & business & " - " & dept & ".xls"

        Application.DisplayAlerts = True
    Else
    If customer = "XXX XXXX" Then
        Application.DisplayAlerts = False
        ActiveWorkbook.SaveAs Filename:=""\\share\XXX XXXX\" & business & " - " & dept & ".xls"
        Application.DisplayAlerts = True
    End If
    End If
    End If

What can I do so that if the user seperates the 2 words it will put them together?

thanks
Sam
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Case_Germany

Active Member
Joined
May 13, 2008
Messages
408
Hi,

you can try it in such a way…

Code:
Sub Test()
    Dim strCustomer As String
    strCustomer = UCase(InputBox("Enter Customer Name", "Customer", "XXX X"))
    strCustomer = Application.WorksheetFunction.Substitute(strCustomer, " ", "")
    MsgBox strCustomer
End Sub
Case_Germany
 
Upvote 0

Forum statistics

Threads
1,191,684
Messages
5,987,998
Members
440,125
Latest member
vincentchu2369

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
Top