ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   choose more than 1 column (https://www.excelbanter.com/excel-programming/279303-choose-more-than-1-column.html)

Andre Croteau

choose more than 1 column
 
Hello,

I am trying to adapt a VBA code seen in these newsgroups, and modify the
following condition to be able to choose more than one column reference:


If Target.Column < 1 Then Exit Sub


The previous command says if my selection is NOT in Column A, then exit
I would like the command to state if not Column A, N, P and from AA to AM
then exit

I'm not sure of the syntax, I tried a few things, but was incorrect.

Can someone help, please?

Thanks

André



Chrissy[_4_]

choose more than 1 column
 
If Target.Column = 1 OR _
Target.Column = 14 OR _
Target.Column = 19 OR _
(Target.Column = 27 AND _
Target.Column <= 39) Then

..... do things

End If


Strictly speaking the () are not needed but use them so
you can read the code more easily.

Chrissy.

"Andre Croteau" wrote in message ...
Hello,

I am trying to adapt a VBA code seen in these newsgroups, and modify the
following condition to be able to choose more than one column reference:


If Target.Column < 1 Then Exit Sub


The previous command says if my selection is NOT in Column A, then exit
I would like the command to state if not Column A, N, P and from AA to AM
then exit

I'm not sure of the syntax, I tried a few things, but was incorrect.

Can someone help, please?

Thanks

André





Andre Croteau

choose more than 1 column
 
Elapsed time 9 minutes!!! I'm impressed
Thank you very much

"Chrissy" wrote in message
...
If Target.Column = 1 OR _
Target.Column = 14 OR _
Target.Column = 19 OR _
(Target.Column = 27 AND _
Target.Column <= 39) Then

..... do things

End If


Strictly speaking the () are not needed but use them so
you can read the code more easily.

Chrissy.

"Andre Croteau" wrote in message

...
Hello,

I am trying to adapt a VBA code seen in these newsgroups, and modify the
following condition to be able to choose more than one column reference:


If Target.Column < 1 Then Exit Sub


The previous command says if my selection is NOT in Column A, then exit
I would like the command to state if not Column A, N, P and from AA to

AM
then exit

I'm not sure of the syntax, I tried a few things, but was incorrect.

Can someone help, please?

Thanks

André







Chrissy[_4_]

choose more than 1 column
 
Sorry about the 9 min delay - I used to send mail every min
but have set it to every 5 mins now so I was a bit slow.

Chrissy.

PS - can you answer my question posted just about yours?

PPS - what are you doing working on a Saturday afternoon?


Andre Croteau wrote
Elapsed time 9 minutes!!! I'm impressed
Thank you very much

"Chrissy" wrote in message
...
If Target.Column = 1 OR _
Target.Column = 14 OR _
Target.Column = 19 OR _
(Target.Column = 27 AND _
Target.Column <= 39) Then

..... do things

End If


Strictly speaking the () are not needed but use them so
you can read the code more easily.

Chrissy.

"Andre Croteau" wrote in message

...
Hello,

I am trying to adapt a VBA code seen in these newsgroups, and modify the
following condition to be able to choose more than one column reference:


If Target.Column < 1 Then Exit Sub


The previous command says if my selection is NOT in Column A, then exit
I would like the command to state if not Column A, N, P and from AA to

AM
then exit

I'm not sure of the syntax, I tried a few things, but was incorrect.

Can someone help, please?

Thanks

André









keepITcool

choose more than 1 column
 
ok ok I'm late!

but try this as an (easier/faster) alternative to Chrissy's solution:

Select Case Target.Column
Case 1, 14, 19, 27 To 39
'do stuff or call procedure
End Select


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Chrissy" wrote:

Sorry about the 9 min delay - I used to send mail every min
but have set it to every 5 mins now so I was a bit slow.

Chrissy.

PS - can you answer my question posted just about yours?

PPS - what are you doing working on a Saturday afternoon?


Andre Croteau wrote
Elapsed time 9 minutes!!! I'm impressed
Thank you very much

"Chrissy" wrote in message
...
If Target.Column = 1 OR _
Target.Column = 14 OR _
Target.Column = 19 OR _
(Target.Column = 27 AND _
Target.Column <= 39) Then

..... do things

End If


Strictly speaking the () are not needed but use them so
you can read the code more easily.

Chrissy.

"Andre Croteau" wrote in message

...
Hello,

I am trying to adapt a VBA code seen in these newsgroups, and
modify the following condition to be able to choose more than one
column reference:


If Target.Column < 1 Then Exit Sub


The previous command says if my selection is NOT in Column A,
then exit I would like the command to state if not Column A, N,
P and from AA to

AM
then exit

I'm not sure of the syntax, I tried a few things, but was
incorrect.

Can someone help, please?

Thanks

André












All times are GMT +1. The time now is 07:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com