I am trying to write a macro that would delete a row if the first character in column A is an asterisk. None of my attempts work.
(using the left function in VBA and searching for ~*)
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
When I search for an asterisk and replace it with any other string and then search for the string, I am able to do it.
(Again, replacing ~*)
<o></o>
Currently I am using this macro, but would like to make the code more efficient by directly deleting rows that start with the asterisk.
<o></o>
Any advice??
<o></o>
Sub DeleteProjectLevel()
Dim LR As Long
'Replace * with a Z
Columns("A:A").Select
Selection.Replace What:="~*", Replacement:="Z", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Insert Shift:=xlToRight
Range("A1").Select
'Create check colum in A
ActiveCell.FormulaR1C1 = "=IF(LEFT(RC[1],1)=""Z"",""<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-comffice:smarttags" /><st1:stockticker>TRUE</st1:stockticker>"",""FALSE"")"
LR = Range("B" & Rows.Count).End(xlUp).Row
Range("A1:A" & LR).Formula = Range("A1").Formula
Application.CutCopyMode = False
Columns("A:A").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.Replace What:="<st1:stockticker>TRUE</st1:stockticker>", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.SpecialCells(xlCellTypeBlanks).Select
Application.CutCopyMode = False
Selection.EntireRow.Delete
'Delete check column
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
<o></o>
End Sub
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
(using the left function in VBA and searching for ~*)
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
When I search for an asterisk and replace it with any other string and then search for the string, I am able to do it.
(Again, replacing ~*)
<o></o>
Currently I am using this macro, but would like to make the code more efficient by directly deleting rows that start with the asterisk.
<o></o>
Any advice??
<o></o>
Sub DeleteProjectLevel()
Dim LR As Long
'Replace * with a Z
Columns("A:A").Select
Selection.Replace What:="~*", Replacement:="Z", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Insert Shift:=xlToRight
Range("A1").Select
'Create check colum in A
ActiveCell.FormulaR1C1 = "=IF(LEFT(RC[1],1)=""Z"",""<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-comffice:smarttags" /><st1:stockticker>TRUE</st1:stockticker>"",""FALSE"")"
LR = Range("B" & Rows.Count).End(xlUp).Row
Range("A1:A" & LR).Formula = Range("A1").Formula
Application.CutCopyMode = False
Columns("A:A").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.Replace What:="<st1:stockticker>TRUE</st1:stockticker>", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.SpecialCells(xlCellTypeBlanks).Select
Application.CutCopyMode = False
Selection.EntireRow.Delete
'Delete check column
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
<o></o>
End Sub
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>