Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
If command with 3 options
I am trying to compare a row of names with a column list.
If the name is in the list I want it to go to the next cell. If the name = NULL then I want it to go to the next cell. If the name = Total I want it to stop. If the name is not in the list I want it to delete the column. Sub NameDelete() With Sheets("RowOfNames") For Each cell In .Range("$1:$1") iRow = 0 On Error Resume Next iRow = Application.Match(cell.Value, Sheets("List").Range("$A:$A"), 0) On Error GoTo 0 If cell.Value = Null Then Resume Next If cell.Value = "Total" Then End If cell.Value < iRow Then cell.EntireColumn.Delete Next cell End With End Sub It runs, but deletes everything. I copied this code from another answer and tried to adopt it to my project. Thanks in advance. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
If command with 3 options
After learning how to use the debug to see my what the variables are set too
and stepping through it, the problem seems to be with: iRow = Application.Match(cell.Value, Sheets("List").Range("$A:$A"), 0) iRow never changes from equaling 0, so it just deletes every column. The NULL and "Total" arguments seem to work fine. "Kevin Porter" wrote: I am trying to compare a row of names with a column list. If the name is in the list I want it to go to the next cell. If the name = NULL then I want it to go to the next cell. If the name = Total I want it to stop. If the name is not in the list I want it to delete the column. Sub NameDelete() With Sheets("RowOfNames") For Each cell In .Range("$1:$1") iRow = 0 On Error Resume Next iRow = Application.Match(cell.Value, Sheets("List").Range("$A:$A"), 0) On Error GoTo 0 If cell.Value = Null Then Resume Next If cell.Value = "Total" Then End If cell.Value < iRow Then cell.EntireColumn.Delete Next cell End With End Sub It runs, but deletes everything. I copied this code from another answer and tried to adopt it to my project. Thanks in advance. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
command line options/switches to print excel file | Excel Discussion (Misc queries) | |||
Print command options | Excel Discussion (Misc queries) | |||
further options following a command button click | Excel Discussion (Misc queries) | |||
Excel Command Line Options | Excel Programming | |||
Command line options | Excel Programming |