• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 577
  • Last Modified:

Excel VB - Case statement - 2 variables

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
irfanibrahim
Asked:
irfanibrahim
  • 2
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
in vba or as cell function?
0
 
irfanibrahimAuthor Commented:
in vba - i know i could use an formula  but there are going to be a lot more conditions
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
irfanibrahimAuthor Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now