Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-28-2015, 09:41 AM
SeattleITguy SeattleITguy is offline Variable arrays from user input Windows Vista Variable arrays from user input Office 2010 32bit
Novice
Variable arrays from user input
 
Join Date: Nov 2014
Posts: 7
SeattleITguy is on a distinguished road
Default Variable arrays from user input

Hello,



I have a VBA script in Excel that prompts the user for input and based off that input it will perform a specific function.

The issue is my team all uses a different input (plus they forget specifics) so I want to create and use an array so that anything they input will match something in the array.

Here is the code:

Code:
Sub Test_Variable_Array()


' This is my array - not sure if this is even correct :(
Dim Customer(2) As String
Customer(0) = "Customer"
Customer(1) = "customer"
Customer(2) = "cust"


InputMsg = "Which view would you like to use"
InputTitle = "Filter View"
DefaultText = "Management"
SpreadsheetTitle = InputBox(InputMsg, InputTitle, DefaultText)
ActiveCell.FormulaR1C1 = "Management"

If SpreadsheetTitle = Customer Then

msgbox ("Match Found")

Else

msgbox ("No Match found")
    
End If
Thanks!!
Reply With Quote
  #2  
Old 01-29-2015, 09:19 AM
SeattleITguy SeattleITguy is offline Variable arrays from user input Windows Vista Variable arrays from user input Office 2010 32bit
Novice
Variable arrays from user input
 
Join Date: Nov 2014
Posts: 7
SeattleITguy is on a distinguished road
Default

Found a working solution...

Instead of creating an array I just used and IF/OR statement:

Code:
If SpreadsheetTitle = "Customer" Or SpreadsheetTitle = "customer" Or SpreadsheetTitle = "cust" Or SpreadsheetTitle = "Cust" Or SpreadsheetTitle = "C" Or SpreadsheetTitle = "c" Then
But I am sure this is not the best way to do it but it works exactly like I need it to.

If anyone knows why this isn't the most efficient way or a better way to do this please chime in.
Reply With Quote
Reply

Tags
array, variable tables, variables



Similar Threads
Thread Thread Starter Forum Replies Last Post
Taking input from InputBox from user SeattleITguy Excel Programming 1 01-28-2015 09:05 AM
Variable arrays from user input User input to a variable on the document dsm1995gst Word VBA 1 09-03-2013 03:43 PM
Variable arrays from user input Replacing text with user input.?.?.? brad1977 Word 3 11-20-2012 10:20 AM
Help with VBA macro - Variable input sc30317 Excel Programming 0 08-31-2011 01:00 PM
Look up an array based on user input johnsmb Excel 2 01-07-2011 01:12 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft