Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Find part of string & delete row

Hi all, use the code below to find "Total" to delete the row, Total is
part of the string & i am not sure how to change the code to find
"Total" even if it is part of a string ?

Sub DeleteTotalSuppSAP()
'
'
Dim i As Long
Dim iLastRow As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = iLastRow To 1 Step -1
If InStr(1, Cells(i, "G").Value, "total", vbTextCompare) Then
Rows(i).Delete
End If
Next i
End Sub

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find part of string & delete row

You code you show identifies cells in column G that contain the substring
total in any case (upper, lower, mixed).

so your code doesn't need to be changed.

--
Regards,
Tom Ogilvy



"Les Stout" wrote in message
...
Hi all, use the code below to find "Total" to delete the row, Total is
part of the string & i am not sure how to change the code to find
"Total" even if it is part of a string ?

Sub DeleteTotalSuppSAP()
'
'
Dim i As Long
Dim iLastRow As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = iLastRow To 1 Step -1
If InStr(1, Cells(i, "G").Value, "total", vbTextCompare) Then
Rows(i).Delete
End If
Next i
End Sub

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Find part of string & delete row

Hi Tom, i have tried it again and cell G11827 has the string "Total due
to supplier" in it, so i want it to delete this row, but it does not ?

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Find part of string & delete row

Maybe you shouldn't be basing the lastrow on column A:

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row

maybe...

iLastRow = Cells(Rows.Count, "G").End(xlUp).Row

If column A ended in row 11, you'd only be looking at rows 1:11.



Les Stout wrote:

Hi Tom, i have tried it again and cell G11827 has the string "Total due
to supplier" in it, so i want it to delete this row, but it does not ?

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Find part of string & delete row

Thant did the trick, thanks Dave

Les Stout

*** Sent via Developersdex http://www.developersdex.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
Delete part of a text string IanP Excel Worksheet Functions 3 April 6th 09 12:34 PM
delete a - if it is the last part of a string deb Excel Discussion (Misc queries) 1 September 21st 08 01:18 AM
Search/Match/Find ANY part of string to ANY part of Cell Value TWhizTom Excel Worksheet Functions 0 July 21st 08 08:16 PM
Use a formula to delete part of a text string? Josh Craig Excel Worksheet Functions 4 June 29th 06 08:19 AM
How do I delete part of a text string in every cell it appears in Chacky Excel Discussion (Misc queries) 3 December 9th 05 07:06 PM


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