Loop to Selection.Delete Shift:=xlUp

Leandroarb

Board Regular
Joined
Oct 7, 2014
Messages
157
Hi,
Please, a need delete cells equal "*".
I try use this code:

Code:
Sub DelTry()
On Error Resume Next
Do While ActiveCell <> ""
    If ActiveCell.Value <> "*" Then
    ActiveCell.Offset(1, 0).Select
    Else
    Selection.Delete Shift:=xlUp
    End If
Loop
End Sub

But... suceless :(

The datas are in columns

[TABLE="width: 83"]
<tbody>[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]03/11/2018[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]04/11/2018[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]15/11/2018[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]02/11/2018[/TD]
[/TR]
[TR]
[TD]10/11/2018[/TD]
[/TR]
[TR]
[TD]11/11/2018[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]17/11/2018[/TD]
[/TR]
[TR]
[TD]18/11/2018[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]24/11/2018[/TD]
[/TR]
[TR]
[TD]25/11/2018[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
[TR]
[TD]*[/TD]
[/TR]
</tbody>[/TABLE]

Every form of help is appreciated.
Thank you.
 
Another option
Code:
Sub RemoveStars()
With Range("A1", Range("A" & Rows.Count).End(xlUp))
   .Replace "~*", True, xlWhole, , , , False, False
   .SpecialCells(xlConstants, xlLogical).Delete xlUp
End With
End Sub
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I did not want to say who I am to not look superb kkk. Just kidding.
Yes Joe, I like basketball, but I do not know how to play very well, I do not know the basics.
This player is known here as "Leandrinho" or "Little Leandro".
Nobody plays basketball as well as you guys!

You are very welcome.

By the way, do you happen to be a basketball fan?
https://en.wikipedia.org/wiki/Leandro_Barbosa
;)
 
Upvote 0
I did not want to say who I am to not look superb kkk. Just kidding.
Yes Joe, I like basketball, but I do not know how to play very well, I do not know the basics.
This player is known here as "Leandrinho" or "Little Leandro".
Nobody plays basketball as well as you guys!

You are very welcome.

By the way, do you happen to be a basketball fan?
https://en.wikipedia.org/wiki/Leandro_Barbosa
;)
 
Upvote 0
I did not want to say who I am to not look superb kkk. Just kidding.
Yes Joe, I like basketball, but I do not know how to play very well, I do not know the basics.
This player is known here as "Leandrinho" or "Little Leandro".
Nobody plays basketball as well as you guys!
I wish I could say I was one of those guys who plays so well!
I am actually 2 inches taller than Leandro, but sadly, I do not have his athleticism (I have a decent inside shot, but never was a good jumper!).

By the way, I don't know if you saw above, but Fluff posted some real nice code that does not use any loops.
 
Last edited:
Upvote 0
I've seen, and I'm going to study it, I find the code very interesting.
You're a tall guy!
When I was younger I even had a good shot in basketball, but as I did not practice much I was very limited. I do not even need to tell you to know that I'm going a little better in soccer, nothing that gets me a place on a professional team but it's a fun time with my kids and friends.
But I am very disappointed with the professional football, many fights, cheats and no example of good conduct for the children, no example of sporting spirit, only money and interests.
If you want to know what real soccer is, watch the Barcelona games.

I wish I could say I was one of those guys who plays so well!

I am actually 2 inches taller than Leandro, but sadly, I do not have his athleticism (I have a decent inside shot, but never was a good jumper!).

By the way, I don't know if you saw above, but Fluff posted some real nice code that does not use any loops.
 
Upvote 0

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top