Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 159
Default Create a macro to find value then delete it

I am trying to create a macro that when the user clicks a button on userform1
it will find a value in sheet1 row b based on the textbox value on
userform1, when it finds the value I want it to delete then entire row. I
have tried but I cannot figure out how to make it do it
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Create a macro to find value then delete it

In the OnClick event of your button, do something like this (modify to
suite):
Dim fRow As Long
On Error GoTo ender
fRow = Columns(2).Find(What:=txt1.Value, _
After:=Cells(1, 2), LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False).Row
Rows(fRow).Delete
Exit Sub
ender:
MsgBox "Value not found"

Mekinnik wrote:
I am trying to create a macro that when the user clicks a button on userform1
it will find a value in sheet1 row b based on the textbox value on
userform1, when it finds the value I want it to delete then entire row. I
have tried but I cannot figure out how to make it do it


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
create a macro that looks for data and delete row andresg1975 Excel Programming 11 February 22nd 08 02:20 PM
How to create a macro to delete multiple rows? gak27 Excel Discussion (Misc queries) 4 December 28th 07 04:51 PM
Create a macro to delete rows if value is less than a specified nu QE Excel Worksheet Functions 5 July 27th 06 08:35 PM
create macro - if cell is 0 delete row pywhacket Excel Worksheet Functions 1 March 15th 06 03:55 PM
have Macro automatically delete and create sheets web_surfer[_2_] Excel Programming 0 February 27th 04 04:03 AM


All times are GMT +1. The time now is 09:49 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"