Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Total 12 columns starting with first non blank column | Excel Worksheet Functions | |||
Copy entire columns starting from a certain cell down | Excel Programming | |||
Deleteing Rows starting with value (text) | Excel Programming | |||
Deleteing | Excel Discussion (Misc queries) | |||
Starting a userform upon starting the file | Excel Programming |