View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Using selected ranges

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/25/04 by Enter Your Name Here
'
Dim A As String, first as Long, last as Long

if selection.Areas.Count 1 or selection.Columns.count 1 then
msgbox "Select single column only, 1 area"
exit sub
End if
first = selection(1).Row
last = selection(selection.count).Row

for i = last to first step -1
If cells(i,selection.column).Value = "FEES" Then
cells(i,Selection.Column).Delete Shift:=xlUp
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"ksnapp " wrote in message
...
Hello,

Im tryin to get a sub or macro that will search a selection(in a
column) and if the individual cells meet a critieria I want to delete
the rows. The part Im havin trouble with is working with the selected
area.

I wrote this one which works if I select the cells individually:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/25/04 by Enter Your Name Here
'
Dim A As String

A = ActiveCell

If A = "FEES" Then


Selection.Delete Shift:=xlUp

End If
End Sub


What do I do to make it work with a selection?


---
Message posted from http://www.ExcelForum.com/