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

hI THERE!I'd like to ask help on how to delete row based on a value entered
in a textbox located in a user form.The userform and the worksheet where the
data to be deleted is stored are located in the same workbook. Example:
After a user input a four digit number it will automatically search in a
specific column of a particular sheet of a workbook. If a match was found the
data will be displayed in there respective control of the form and when an
OKcommand button is clicked the found data will be deleted. Pls.. Help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default DELETING ROW

This will work. It needs modified if the value could be found more
than once and you want to delete all instances.

Dim miRow As Long

Private Sub CommandButton1_Click()
If miRow = 0 Then Exit Sub
If Label2 = "Found!" Then
Sheets("Sheet1").Rows(miRow).Delete
Label2 = ""
End If
miRow = 0
End Sub

Private Sub TextBox1_AfterUpdate()
Dim iFind As Integer

iFind = TextBox1.Value
Do
miRow = miRow + 1
If iFind = Sheets("Sheet1").Range("A" & miRow) Then
Label2.Caption = "Found!"
Exit Sub
End If
Loop Until Sheets("Sheet1").Range("A" & iRow + 1) = ""
Label2 = "Not found."
End Sub

Hth,
Merjet


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default DELETING ROW

Public cell as Range

Private Sub TextBox1_Change()
Dim rng as Range, rng1 as Range
Dim s as String

if len(Textbox1.Value) = 4 then
if isnumeric(Textbox1.Value) then
set cell = Nothing
Textbox2.value = ""
Textbox3.Value = ""
s = Textbox1.Value
set rng = Worksheets("Data").Range("C:C")
Set rng1 = rng.Find(What:=s, _
After:=rng(rng.count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
if not rng1 is nothing then
set cell = rng1
Textbox2.value = cell.offset(0,-2)
Textbox3.Value = cell.offset(0,-1)
end if
end if
end if
End Sub


Private Sub CommandButton1_Click()
if not cell is nothing then
if len(trim(textbox1.value)) = 4 then
Textbox1.Value = ""
Textbox2.Value = ""
Textbox3.Value = ""
cell.EntireRow.Delete
set cell = Nothing
end if
end if
end Sub

--
Regards,
Tom Ogilvy

"Chin
x21" wrote:

hI THERE!I'd like to ask help on how to delete row based on a value entered
in a textbox located in a user form.The userform and the worksheet where the
data to be deleted is stored are located in the same workbook. Example:
After a user input a four digit number it will automatically search in a
specific column of a particular sheet of a workbook. If a match was found the
data will be displayed in there respective control of the form and when an
OKcommand button is clicked the found data will be deleted. Pls.. Help!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default DELETING ROW


Thanks Tom! You got what I mean.. I've been waiting for your response cause
I find it easy to understood.
"Tom Ogilvy" wrote:

Public cell as Range

Private Sub TextBox1_Change()
Dim rng as Range, rng1 as Range
Dim s as String

if len(Textbox1.Value) = 4 then
if isnumeric(Textbox1.Value) then
set cell = Nothing
Textbox2.value = ""
Textbox3.Value = ""
s = Textbox1.Value
set rng = Worksheets("Data").Range("C:C")
Set rng1 = rng.Find(What:=s, _
After:=rng(rng.count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
if not rng1 is nothing then
set cell = rng1
Textbox2.value = cell.offset(0,-2)
Textbox3.Value = cell.offset(0,-1)
end if
end if
end if
End Sub


Private Sub CommandButton1_Click()
if not cell is nothing then
if len(trim(textbox1.value)) = 4 then
Textbox1.Value = ""
Textbox2.Value = ""
Textbox3.Value = ""
cell.EntireRow.Delete
set cell = Nothing
end if
end if
end Sub

--
Regards,
Tom Ogilvy

"Chin
x21" wrote:

hI THERE!I'd like to ask help on how to delete row based on a value entered
in a textbox located in a user form.The userform and the worksheet where the
data to be deleted is stored are located in the same workbook. Example:
After a user input a four digit number it will automatically search in a
specific column of a particular sheet of a workbook. If a match was found the
data will be displayed in there respective control of the form and when an
OKcommand button is clicked the found data will be deleted. Pls.. Help!

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
Deleting the text without deleting the formula gems04 Excel Worksheet Functions 3 January 30th 09 11:21 PM
Deleting cell data without deleting formula Tom Hall Excel Discussion (Misc queries) 4 October 29th 06 04:07 PM
deleting values in a worksheet without deleting the formulas patti Excel Worksheet Functions 1 October 28th 05 09:49 PM
how prevent formula in cell from deleting when deleting value???? sh-boom New Users to Excel 1 September 30th 05 06:12 PM
Deleting Hyphens or Dashes from multiple cells without deleting the remaining content rmaloy Excel Programming 5 February 9th 04 01:59 AM


All times are GMT +1. The time now is 04:54 PM.

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"