LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Deleteing columns starting at a certain row.

I currently have a program that compares names in row 1 with another
spreadsheet and deletes the columns if the names aren't there. This was easy
as there was only 1 column under a name.

Now there is another column that I do not want at all. So I need it to
delete all the columns for names that are not there and the first two columns
for those that are.

Here is my current code:

With Sheets("Shreveport").Rows(2).Delete
Dim i As Long
Dim lastCol As Long
With Sheets("Shreveport")
lastCol = .Cells(1, "IV").End(xlToLeft).Column
For i = lastCol To 1 Step -1
If Len(Trim(.Cells(1, i))) < 0 Then
If Application.CountIf(Workbooks("Employee List for
Payroll1").Worksheets("List").Columns(2), .Cells(1, i)) = 0 Then
.Columns(i).Delete .Columns(i + 1).Delete
End If
End If
Next
End With

Any help would be appreciated.

Thanks.
 
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
Total 12 columns starting with first non blank column BillyRogers Excel Worksheet Functions 9 September 27th 07 09:12 PM
Copy entire columns starting from a certain cell down cheeser83 Excel Programming 2 August 1st 06 03:52 PM
Deleteing Rows starting with value (text) chesspupil Excel Programming 2 May 22nd 06 12:53 AM
Deleteing koba Excel Discussion (Misc queries) 2 November 25th 05 04:11 AM
Starting a userform upon starting the file Fritznel Excel Programming 1 July 28th 03 05:37 AM


All times are GMT +1. The time now is 02:16 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"