Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select entire columns

I have a range activated Range(strPlageSélectionnée).Activate, and i'm looking for selecting their entire columns in order to delete them. I know that to select a column there is a specific formula ActiveCell.EntireColumn.Select and to delete one column it's ActiveCell.EntireColumn.Delete

But how can i select and delete many columns at once. Is there any specific formula ?

Thanks for your help

like image 692
R.Omar Avatar asked Jan 06 '23 13:01

R.Omar


2 Answers

Don't select columns to delete them, in fact you should rarely be selecting anything programmatically.

I suspect your columns are not next to each other so this will work.

Range("C:C,F:F,I:I").Delete

Notice .select and selection were chopped off and the code combined to one line instead of:

Range("C:C,F:F,I:I").select
Selection.Delete
like image 152
Dan Donoghue Avatar answered Jan 14 '23 17:01

Dan Donoghue


You can just replace ActiveCell with the Range.

Range("C4:F10").EntireColumn.Delete
like image 25
crimmyjif Avatar answered Jan 14 '23 17:01

crimmyjif