Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Another code for deleting row

Sorry to post on this again but I realised I need to delete another row on a
different sheet using the same command button click event. Here is the code
I have added to the code that deletes rows on another sheet:

Dim anotherrng As Range, anotherres As Variant, anotherrng1 As Range
Dim lookup_value
lookup_value = Sheets("Blend Sheet").Range("O3").Text
Set rng = Worksheets("Blends Produced").Range("I2:I6000")

res = Application.Match(lookup_value, rng, 0)

If Not IsError(res) Then
Set rng1 = rng(res)
rng1.EntireRow.Delete
MsgBox "Component Deleted"
Else
MsgBox "No Match "
End If

Unload Me

End Sub

The code is supposed to lookup the number in 'Blend Sheet'! O3 and find it
in 'Blends Produced'! I2:I6000 and then delete the entire row. But it just
don't work.....I keep getting "No Match ". Could some kind soul please
show me where I have stuffed up.

gregorK


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Another code for deleting row

Try this:

res = Application.WorksheetFunction.Match(lookup_value, rng, 0

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Another code for deleting row

Is there a real reason you used .Text in:
lookup_value = Sheets("Blend Sheet").Range("O3").Text

You might be changing something that should be .value.

What kind of data is in Range("o3")?

gregork wrote:

Sorry to post on this again but I realised I need to delete another row on a
different sheet using the same command button click event. Here is the code
I have added to the code that deletes rows on another sheet:

Dim anotherrng As Range, anotherres As Variant, anotherrng1 As Range
Dim lookup_value
lookup_value = Sheets("Blend Sheet").Range("O3").Text
Set rng = Worksheets("Blends Produced").Range("I2:I6000")

res = Application.Match(lookup_value, rng, 0)

If Not IsError(res) Then
Set rng1 = rng(res)
rng1.EntireRow.Delete
MsgBox "Component Deleted"
Else
MsgBox "No Match "
End If

Unload Me

End Sub

The code is supposed to lookup the number in 'Blend Sheet'! O3 and find it
in 'Blends Produced'! I2:I6000 and then delete the entire row. But it just
don't work.....I keep getting "No Match ". Could some kind soul please
show me where I have stuffed up.

gregorK


--

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
Deleting row using vb code? hol Excel Discussion (Misc queries) 4 November 30th 07 02:43 PM
VBA Code for Deleting a Row [email protected] Excel Worksheet Functions 3 September 6th 07 03:23 PM
Deleting Code from VBA Noemi Excel Discussion (Misc queries) 1 January 24th 06 08:55 AM
deleting code by macro jriehl Excel Programming 2 June 29th 04 09:43 AM
Deleting code in a file with code.. KimberlyC Excel Programming 3 March 4th 04 09:24 PM


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