?
Solved

Excel VB - Case statement - 2 variables

Posted on 2011-02-23
4
Medium Priority
?
566 Views
Last Modified: 2012-05-11
Hi there

I am trying to implement a CASE statement in VB with 2 variables.

I have attached a spreadsheet of how i want this to work.

There are basically 2 columns with UoM1 and UoM2.

The code needs to run down each row and check what's in UoM1 and UoM2.

Column E shows the calculations to do when it meets those conditions.

((I know conversions are not correct - this is just an example!))

How do i express this in VB code to run in excel?

Many thanks
Irfan convert-Case.xls
0
Comment
Question by:irfanibrahim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 34959928
in vba or as cell function?
0
 

Author Comment

by:irfanibrahim
ID: 34963283
in vba - i know i could use an formula  but there are going to be a lot more conditions
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1500 total points
ID: 34963409
you could do something like this:

r = 0.01
UoM1 = "MM"
UoM2 = "M"
select case UoM1 & "-" & UoM2
  case "MM-M"
     r = r * 100
  case "M-M"
     r = r * 1000
   case "EA-EA"
     r =  r
   case "M-MM"
     r = r / 100
end select

Open in new window

0
 

Author Closing Comment

by:irfanibrahim
ID: 34994490
hi there
i manged to get it working - the end result is a bit different to the example you gave but it did help me work it out
thanks
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question