ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   wild card * (https://www.excelbanter.com/excel-programming/400867-wild-card-%2A.html)

transferxxx

wild card *
 
My macro below is not working properly:

Sub Deletedepo()


With ActiveSheet
..DisplayPageBreaks = False
StartRow = 1
EndRow = .Cells(.Rows.Count, "C").End(xlUp).Row
For Lrow = EndRow To StartRow Step -1

If .Cells(Lrow, "C").Value = "CASH DEPOSIT *" Then

..Rows(Lrow).Delete
End If
Next
End With
End Sub

I would like to delete all rows with cells in column c containing e.g
Cash deposit GBP1000
Cash deposit Euro 50
But the wild card * is not working - can someone pls correct my macro
Thxs



Faisal...

wild card *
 
Try this:

Sub Deletedepo()

With ActiveSheet
..DisplayPageBreaks = False
StartRow = 1
EndRow = .Cells(.Rows.Count, "C").End(xlUp).Row
For Lrow = EndRow To StartRow Step -1

strVal=.Cells(Lrow, "C").Value
If LEFT(strVal,12) = "CASH DEPOSIT" Then

..Rows(Lrow).Delete
End If
Next
End With
End Sub


On Nov 9, 11:18 am, transferxxx wrote:
My macro below is not working properly:

Sub Deletedepo()

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = .Cells(.Rows.Count, "C").End(xlUp).Row
For Lrow = EndRow To StartRow Step -1

If .Cells(Lrow, "C").Value = "CASH DEPOSIT *" Then

.Rows(Lrow).Delete
End If
Next
End With
End Sub

I would like to delete all rows with cells in column c containing e.g
Cash deposit GBP1000
Cash deposit Euro 50
But the wild card * is not working - can someone pls correct my macro
Thxs




transferxxx

wild card *
 
thxs it works - but i don't understand why * can't make it - can someone
explain it to me thxs

"Faisal..." wrote:

Try this:

Sub Deletedepo()

With ActiveSheet
..DisplayPageBreaks = False
StartRow = 1
EndRow = .Cells(.Rows.Count, "C").End(xlUp).Row
For Lrow = EndRow To StartRow Step -1

strVal=.Cells(Lrow, "C").Value
If LEFT(strVal,12) = "CASH DEPOSIT" Then

..Rows(Lrow).Delete
End If
Next
End With
End Sub


On Nov 9, 11:18 am, transferxxx wrote:
My macro below is not working properly:

Sub Deletedepo()

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = .Cells(.Rows.Count, "C").End(xlUp).Row
For Lrow = EndRow To StartRow Step -1

If .Cells(Lrow, "C").Value = "CASH DEPOSIT *" Then

.Rows(Lrow).Delete
End If
Next
End With
End Sub

I would like to delete all rows with cells in column c containing e.g
Cash deposit GBP1000
Cash deposit Euro 50
But the wild card * is not working - can someone pls correct my macro
Thxs





Dave Peterson

wild card *
 
This is looking for an asterisk--not a wildcard:
If .Cells(Lrow, "C").Value = "CASH DEPOSIT *" Then
That's the way "=" works.

You may want to look at VBA's help for Like (where you can use wildcards).

transferxxx wrote:

thxs it works - but i don't understand why * can't make it - can someone
explain it to me thxs

"Faisal..." wrote:

Try this:

Sub Deletedepo()

With ActiveSheet
..DisplayPageBreaks = False
StartRow = 1
EndRow = .Cells(.Rows.Count, "C").End(xlUp).Row
For Lrow = EndRow To StartRow Step -1

strVal=.Cells(Lrow, "C").Value
If LEFT(strVal,12) = "CASH DEPOSIT" Then

..Rows(Lrow).Delete
End If
Next
End With
End Sub


On Nov 9, 11:18 am, transferxxx wrote:
My macro below is not working properly:

Sub Deletedepo()

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = .Cells(.Rows.Count, "C").End(xlUp).Row
For Lrow = EndRow To StartRow Step -1

If .Cells(Lrow, "C").Value = "CASH DEPOSIT *" Then

.Rows(Lrow).Delete
End If
Next
End With
End Sub

I would like to delete all rows with cells in column c containing e.g
Cash deposit GBP1000
Cash deposit Euro 50
But the wild card * is not working - can someone pls correct my macro
Thxs





--

Dave Peterson


All times are GMT +1. The time now is 03:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com