ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   deleting a variable number of columns (https://www.excelbanter.com/excel-programming/272816-deleting-variable-number-columns.html)

Rob Barnard

deleting a variable number of columns
 
Hi Phillip,

You might like to try something like:

ActiveSheet.Range(Cells(1,1),Cells
(1,delCol)).EntireColumn.Delete

:-)

Rob

-----Original Message-----
Hi there,

I've got a little problem which i hope someone will be

able to help me
with please.

I have a macro that counts the number of columns as it

processes a table
of data, this number goes into a variable called

ColCount. After a
variable number of column headings (the first row of the

table contains
the column headings) the headings change from letters to

numbers, these
numbered column headings are not only included in

ColCount but also in a
new counter called SaveCol. This is becuase i need to

delete all the
columns before those starting with numbers.

At the moment all i have is another variable called

delCol which is set
to:

delCol = ColCount - SaveCol.

I think i need to use somethink like:
ActiveSheet.Columns("A:delCol").EntireColumn.Dele te

but as im sure you can alls see "A:delCol" is not allowed.

Any help would be greatly appreciated

Thanks

Phillip

*** Sent via Developersdex http://www.developersdex.com

***
Don't just participate in USENET...get rewarded for it!
.


phillip harrison

deleting a variable number of columns
 
Rob

That works a treat.

Thank you for your help

Phillip



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

steve

deleting a variable number of columns
 
Phillip,

You can also use the following notation (just another way)

ActiveSheet.Range(Columns(1st column #),Columns(last column #)).Delete

this notation just makes it clearer that you are working on columns.

steve

"phillip harrison" wrote in message
...
Rob

That works a treat.

Thank you for your help

Phillip



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





All times are GMT +1. The time now is 09:46 PM.

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