is Select Case best way of doing this

Kavy

Well-known Member
Joined
Jun 25, 2007
Messages
607
Good day,

Its been a long time since I have last posted, I have missed this forum!

Anyway,

I have to populate a cell with different types of data, based on the code is in an adjacent cell. For example if the code in the adjacent cell reads "GL", I then have to populate the cell with the "owners name" the "size", other codes require different variables.

All the information needed for each variable (i.e. owners name) is on the same line as the cell I am trying to populate.

I am trying to think of the best way to do this, there are about 33 codes, each with different variable requirements, some requiring up to 8 different variables.

I was going to use a "Select Case" method, where it sees the code, it then selects that case, and with in the code it steals the variable data from the proper cells.

Another method I was going to use, was what I just mentioned, but have a second select case for the variables, instead of if statements.

Thank you for any tips!!

Kavy
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi Kavy,

Perhaps your system would be easier to maintain if you created a table in your workbook with a field for the code and another 7-10 fields for the variables that you want to place when that code is selected.

Your VBA code could then lookup the list of variables in your table instead of with the Select...Case statement.

You could do what you describe using Select...Case; however that means you need to edit your VBA code each time you add codes or make revisions.
 
Upvote 0
Why a second select case?

What do all the Ifs do?
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,977
Members
449,200
Latest member
Jamil ahmed

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
Back
Top