Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Find and delete

I am making a database in excel, and I have come across a problem.
want the user to be able to type a user ID in a cell and press a butto
labelled delete. I then want the macro to search the database workshee
for a cell containing EXACTLY the same as the input cell and delete th
row. Any ideas?

Thanks in advance!

Dav

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find and delete

Use the find method. Turn on the macro recorder and do Edit=Find. Turn
off the recorder.

Now you can generalize the code to replace you hardcoded search term with a
reference to the cell where the ID will be entered.

--
Regards,
Tom Ogilvy

"newmand2 " wrote in message
...
I am making a database in excel, and I have come across a problem. I
want the user to be able to type a user ID in a cell and press a button
labelled delete. I then want the macro to search the database worksheet
for a cell containing EXACTLY the same as the input cell and delete the
row. Any ideas?

Thanks in advance!

Dave


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Find and delete

yes, but how do i do that? I know how to record the macro, its just
case of retrieving the input as a variable in the coding, and i trie
the edit = find thing, but for some reason u cant record it. Thank
agai

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find and delete

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 4/30/2004 by OGILVTW
'

'
Cells.Find(What:="value", After:=ActiveCell, LookIn:=xlFormulas, LookAt
_
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
End Sub


recorded fine for me.

Then to make it more general as an example (search for a term on the
activesheet that is found on a worksheet named Sourcesheet in cell B9)

Dim rng as Range
Dim rng1 as Range

set rng1 = Worksheets("Sourcesheet").Range("B9").Value

set rng = Cells.Find(What:=rng1.Value, After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)

if not rng is nothing then
msgbox "found in " & rng.Address(external:=True)
else
msgbox "Not found"
End if

--
Regards,
Tom Ogilvy


"newmand2 " wrote in message
...
yes, but how do i do that? I know how to record the macro, its just a
case of retrieving the input as a variable in the coding, and i tried
the edit = find thing, but for some reason u cant record it. Thanks
again


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



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
Find and delete Philip Drury Excel Worksheet Functions 3 October 4th 07 07:33 PM
Find and delete! Philip Drury Excel Discussion (Misc queries) 0 October 3rd 07 02:36 PM
Find and Delete Karen[_2_] Excel Worksheet Functions 2 June 19th 07 11:04 PM
find a value and delete that row TUNGANA KURMA RAJU Excel Discussion (Misc queries) 11 January 29th 07 09:50 AM
Find delete Jean-Francois Excel Discussion (Misc queries) 3 January 11th 05 05:25 PM


All times are GMT +1. The time now is 07:15 AM.

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

About Us

"It's about Microsoft Excel"