multipe or statements
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Multipe OR statements?

Multipe OR statements?

resolvedResolved · Urgent Priority · Version 2003

replyReply Thu 30 Oct 2008, 14:35Delegate Angela said...

Angela has attended:
Excel VBA Intro Intermediate course

Multipe OR statements?

Hi

I'm creating a user form and i want when the user click a button it will show a list of items that they have selected from a previous sheet with boxes.

So How do I write a code for multiple 'OR' staments

for example I want to say if

Cell A2 = true then dsiplay contents of cell E2, if Cell A3 is true then display contents of E3 etc...
At the end they should have a list of items on the user form.

I can get one item to show with this code

Private Sub cmdAdd_Click()

Set ws = Worksheets("Exchange Input")

ws.Visible = True

If Range("A2").Value = True Then

Me.txtExchanges.Value = Range("E2")

End If

End sub


If I add multiple if statements, if all the cells are true only one item is listed on the form.

For upcoming training course dates see: Pricing & availability

replyReply Mon 3 Nov 2008, 09:29Trainer Stephen said...

RE: multipe OR statements?

Hi Angela

Thank you for your question

It is difficult to advise without seeing your spreadsheet directly.

My first thought however is that ratherthan using an OR statement, a better approach might be a SELECT CASE structure.

I suggest you try this.

If this doesnt work perhaps you could email me the spreadsheet in question and I will look into it

Regards

Stephen

 

Please browse our web site to find out more about
vba-excel-training and other Microsoft training courses.

Excel tip:

Naming and Using Constants

Constants make calculations easier so worksheets are more easily understood. Constant values also need to be given relevant and memorably names. It is also easier to change the value of a constant.

For example:
Instead of entering 17.5% in each cell when you generate a VAT amount you could name a Constant "VAT" and assigning a "0.175" value to it. To do this:

From the 'Insert' menu select 'Name', then select 'Define'.

Enter the constant

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard