Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Search from bottom of column up column and delete to top

New to Excel VBA, trying to find out:

1. How to search (or find) from the bottom of a column upwards.

2. Once the search result is found I need to delete all the column data from
that result up to row 2 of the column.

Can anyone help? I've been messing around with this for a few weeks now and
cannot figure it out - sorry!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Search from bottom of column up column and delete to top

Start at the top of the column and look for the previous value.

dim FoundCell as range
with worksheets("somesheet")
with .range("e:e") 'for example
Set foundcell = .Cells.Find(What:="whatareyoulookingfor", _
After:=.Cells(1), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False)
end with

if foundcell is nothing then
'not found, what should happen
else
if foundcell.row < 2 then
msgbox "not found below 1--what should happen here"
else
.rows(2 & ":" & foundcell.row).delete
end if
end if
end with

Jools wrote:

New to Excel VBA, trying to find out:

1. How to search (or find) from the bottom of a column upwards.

2. Once the search result is found I need to delete all the column data from
that result up to row 2 of the column.

Can anyone help? I've been messing around with this for a few weeks now and
cannot figure it out - sorry!


--

Dave Peterson
Reply
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
Search for a column based on the column header and then past data from it to another column in another workbook minkokiss Excel Programming 2 April 5th 07 01:12 AM
Based on a condition in one column, search for a year in another column, and display data from another column in the same row look [email protected] Excel Programming 2 December 30th 06 06:23 PM
Based on a condition in one column, search for a year in another column, and display data from another column in the same row look [email protected] Excel Discussion (Misc queries) 1 December 27th 06 05:47 PM
Search Column - Find Multiple Entries - Sum Then Delete to Single Entry Ledge Excel Programming 5 June 19th 06 08:25 PM
dislike jump bottom of column by double-clicking the bottom of cel Joe Excel Discussion (Misc queries) 1 April 9th 06 09:27 PM


All times are GMT +1. The time now is 10:22 AM.

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"