Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro to delete unwanted colomns

Hi,
I have following file. i need to delete unwanted colomns and colomn.

================================================== =================
Item Feb1
Feb2 and so on
Qty Amt Dep COST COGS Qty Amt Dep Cost COGS
cup 1 3 3 234 23 4 4 3 234
23
coffee 2 5 3 23 56 5 2 3 234 23
paper 3 2 3 23 56 7 8 3 234 23

================================================== =================

Important Each col except "item" contains sub- colomns (i.e Qty
Amount %ofDep AvgCost COGS AvgCOGS). I need to
keep col name Item. I need to keep col name Qty and Amount. I want to
delete all other colomns i.e Amt, Dep,Cost, COGS, There are ALSO
several blank titles colomns also which i want to delete.

Required file

================================================== =================
Item Feb1 Feb2 Feb3 and so on.
Qty Amount Qty Amount Qty Amount
cup 1 3 4 4 2 3
coffee 2 5 5 2 4 3
paper 3 2 7 8 5 3

================================================== =================

I am looking for macro for that. Any advice would be highly
appreciated

thanks in advance for reading above and solution.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Macro to delete unwanted colomns

Hi

Your question is a bit amigious.
Looking at your data Column Amt in first table seems to be Amount column in
result table.

Try this and change Amt to Amount if required.

Sub RemoveColumns()
targetRow = 2
LastCol = Cells(targetRow, Columns.Count).End(xlToLeft).Column
For c = LastCol To 2 Step -1
If Cells(targetRow, c).Value < "Qty" And Cells(targetRow, c).Value <
"Amt" Then
Columns(c).Delete
End If
Next
End Sub

Best regards,
Per

"mshak" skrev i meddelelsen
...
Hi,
I have following file. i need to delete unwanted colomns and colomn.

================================================== =================
Item Feb1
Feb2 and so on
Qty Amt Dep COST COGS Qty Amt Dep Cost COGS
cup 1 3 3 234 23 4 4 3 234
23
coffee 2 5 3 23 56 5 2 3 234 23
paper 3 2 3 23 56 7 8 3 234 23

================================================== =================

Important Each col except "item" contains sub- colomns (i.e Qty
Amount %ofDep AvgCost COGS AvgCOGS). I need to
keep col name Item. I need to keep col name Qty and Amount. I want to
delete all other colomns i.e Amt, Dep,Cost, COGS, There are ALSO
several blank titles colomns also which i want to delete.

Required file

================================================== =================
Item Feb1 Feb2 Feb3 and so on.
Qty Amount Qty Amount Qty Amount
cup 1 3 4 4 2 3
coffee 2 5 5 2 4 3
paper 3 2 7 8 5 3

================================================== =================

I am looking for macro for that. Any advice would be highly
appreciated

thanks in advance for reading above and solution.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro to keep specific name colomns and delete all others myshak Excel Discussion (Misc queries) 0 March 9th 09 11:01 PM
delete unwanted colomns, empty colomns myshak Excel Programming 0 March 9th 09 11:00 PM
macro to delete unwanted data pm Excel Discussion (Misc queries) 2 May 2nd 07 06:50 PM
Macro to delete unwanted sheets Sal Excel Discussion (Misc queries) 5 March 15th 07 09:33 PM
I need a macro to delete unwanted data Jason[_36_] Excel Programming 7 April 25th 05 11:36 AM


All times are GMT +1. The time now is 01:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"