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
 

Some videos you may like

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Jerry Sullivan

MrExcel MVP
Joined
Mar 18, 2010
Messages
8,787
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.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,216
Office Version
  1. 365
Platform
  1. Windows
Why a second select case?

What do all the Ifs do?
 

Watch MrExcel Video

Forum statistics

Threads
1,122,193
Messages
5,594,774
Members
413,934
Latest member
austinb

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
Top