View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Delete column if a cell is not named

Hi Mirja,

Sub test()
On Error Resume Next
sName = ""
sName = Range("A1").Name.Name
On Error GoTo 0
If sRangeName = "" Then
MsgBox "not named"
Else
MsgBox sName
End If
End Sub

Regards,
Peter T

"Mirja" wrote in message
...
I would like to do the following within VBA:
- Select range from first cell to last cell in first row of a database.
- Find arguments in this range (e.g. if cell value = "Sales" then name the
cell = "Sales"). I have several arguments.
- Afterwards, I want to delete all columns that do not contain these
arguments (in the example above: If the first cell of a column is not
"Sales", then delete the column).

My main problem: How do I check if a cell is named or not?

Thank you in advance!
Mirja