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 What command after then statement?

The following code is supposed to compare all the names in row 1 with a list
on another worksheet. If the name is in the list it continues on, if the
name is not in the list it deletes the column, if the cell is empty (NULL)
then I want it to ignore it and go to the next cell.

As the code is now it deletes a couple of NULL cell columns at the begnning
of the worksheet, doesn't delete a few more, then deletes a couple of names
(properly as they are not on the list), then after it doesn't delete a column
(properly again because the name is on the list) it just deletes all the NULL
columns throughtout the rest of the row and doesn't delete anymore names.

The Null columns between names is to make the spreadsheet much easier to
view, so I want to keep them, I just want the program to ignore them and move
on.


Dim iRow As String
Dim cell As Range
Sub OfficeNameDelete()

With Sheets("Office")
For Each cell In .Range("$1:$1")
iRow = 0
On Error Resume Next
iRow = Application.VLookup(cell, Sheets("List").Range("$A:$B"), 1)
On Error GoTo 0
If cell = "TOTAL" Then
End
ElseIf cell = Null Then
Resume Next
ElseIf iRow < cell Then
cell.EntireColumn.Delete
End If
Next cell
End With
End Sub

Thanks in advance. I am off to buy a VBA for dummies book now.
 
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
command to do "nothing" in If/Then statement? Janis Excel Programming 4 August 18th 06 11:18 PM
command to do "nothing" in If/Then statement? #2 Janis Excel Programming 1 August 18th 06 09:54 PM
Hide Row command using if statement DME Excel Worksheet Functions 2 February 16th 05 03:44 PM
VBA Command to Look at cell in an If statement Wolf New Users to Excel 3 December 27th 04 11:27 PM
How do you use the text command in an if statement ie. if....,tex. Ken Biles(PARSONS) Excel Programming 1 November 9th 04 08:11 PM


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

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

About Us

"It's about Microsoft Excel"