VBA - Select multiple columns

PIP7410

New Member
Joined
Jan 26, 2012
Messages
12
Hi all...please help! I'm new to the wonderful world of VBA :)
I have a spreadsheet with many pick lists. Some of these should only allow a single item to be selected, some should permit multiples.

I have the code to allow multiples to be selected, and have got it working so that it selects a single column only. Problem is, I need to it allow multiples in 3 columns, but not the rest. Any help would be appreciated! At present I need it to allow multiples on columns 11, 12 and 13, but can only get it working on a single row (11).

oldVal = Target.Value
Target.Value = newVal
If Target.Column = 11 Then
If oldVal = "" Then
'do nothing
Else

Thank you in advance!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hi all...please help! I'm new to the wonderful world of VBA :)
I have a spreadsheet with many pick lists. Some of these should only allow a single item to be selected, some should permit multiples.

I have the code to allow multiples to be selected, and have got it working so that it selects a single column only. Problem is, I need to it allow multiples in 3 columns, but not the rest. Any help would be appreciated! At present I need it to allow multiples on columns 11, 12 and 13, but can only get it working on a single row (11).

oldVal = Target.Value
Target.Value = newVal
If Target.Column = 11 Then
If oldVal = "" Then
'do nothing
Else
For continuous columns (like you asked for), try this If..Then line of code...

If Target.Column>10 And Target.Column < 14 Then
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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