#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Excel 2003

I have a spreadhseet whose columns change each month. I want to automatically
delete all the columns in the spreadsheet ecept for the first and last
columns. Is there a way to do this automatically?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Excel 2003

Sub columnator()

Set r = ActiveSheet.UsedRange
nLastColumn = r.Columns.Count + r.Column - 1
nFirstcolumn = r.Column

For i = nLastColumn - 1 To nFirstcolumn + 1 Step -1
Columns(i).EntireColumn.Delete
Next

End Sub
--
Gary's Student
gsnu200712


"Kim Kautzmann" wrote:

I have a spreadhseet whose columns change each month. I want to automatically
delete all the columns in the spreadsheet ecept for the first and last
columns. Is there a way to do this automatically?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Excel 2003

Thanks so much. This works perfectly.

"Gary''s Student" wrote:

Sub columnator()

Set r = ActiveSheet.UsedRange
nLastColumn = r.Columns.Count + r.Column - 1
nFirstcolumn = r.Column

For i = nLastColumn - 1 To nFirstcolumn + 1 Step -1
Columns(i).EntireColumn.Delete
Next

End Sub
--
Gary's Student
gsnu200712


"Kim Kautzmann" wrote:

I have a spreadhseet whose columns change each month. I want to automatically
delete all the columns in the spreadsheet ecept for the first and last
columns. Is there a way to do this automatically?

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
import Excel 2003 file into Outlook 2003 - NO NAMED RANGES?? lewisma9 Excel Discussion (Misc queries) 0 February 27th 07 12:23 AM
Copying Excel 2003 Selection into Outlook 2003 HTML E-Mail Message [email protected] Excel Discussion (Misc queries) 0 July 10th 06 03:07 PM
Upgrade from Excel 2000 to Excel 2003 without MS Office 2003? brigida3 Excel Discussion (Misc queries) 1 January 22nd 06 05:13 PM
Exporting addresses from excel 2003 to outlook 2003 Linda H Excel Discussion (Misc queries) 0 November 14th 05 06:58 PM
Excel 2003 Database Driver Visual FoxPro 7 on Server 2003. Cindy Winegarden Excel Discussion (Misc queries) 0 November 28th 04 12:07 AM


All times are GMT +1. The time now is 05:49 PM.

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"