hi
i need a help with a macro
i need that if cells value in column "B" sheet1 is non numeric or letter delete the entire row
thanks
hi
i need a help with a macro
i need that if cells value in column "B" sheet1 is non numeric or letter delete the entire row
thanks
Try recording a macro using F5/Special to see if that produces the correct result. Your question is not very clear. Letter is by definition, non-numeric.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
hi
sorry
i meant that cell value is not numbers and not letters
This one scrubs rows with empty cells in column B too, remove
[VBA]IsEmpty(Cells(rw, "B")) Or[/VBA]
if you don't want this.
[VBA]Sub blah()
Set xxx = Intersect(ActiveSheet.UsedRange, Columns("B"))
For rw = xxx.Row + xxx.Rows.Count - 1 To xxx.Row Step -1
If IsEmpty(Cells(rw, "B")) Or Not IsNumeric(Cells(rw, "B")) Then ActiveSheet.Rows(rw).Delete
Next rw
End Sub
[/VBA]
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
Try this
[VBA]
Option Explicit
Sub DelChars()
Dim rng As Range, i As Long
Dim RegExp
Set RegExp = CreateObject("VBScript.RegExp")
With RegExp
.Global = True
.IgnoreCase = True
End With
RegExp.Pattern = "\w"
Set rng = Intersect(Columns(2), ActiveSheet.UsedRange)
For i = rng.Cells.Count To 1 Step -1
If Not (RegExp.test(rng(i))) Then rng(i).EntireRow.Delete
Next
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
hi
thanks
when i run this macro it deletes every thing even if the cells value is a number or a letter
i can not get it to work
it does not delete stuff like "---------------------"
which macro?Originally Posted by oleg_v
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
this one
Originally Posted by mdmackillop
I suspect a regex engine flavour problem with mdmackillop's solution.
Does mine work for you?
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
hi
it seems nothing is working
i attached the example file
look at the column "B" and if the cell does not contain number or letters delete
the row.
only for if this condition exists delete the row else not
thanks
Works for me on your sample. What Excel version are you using?
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Hi Olag,
I didn't test Pascal's, but Malcom's worked for me as described (xl2003 currently, but leaving...).
I am curious if we are understanding. In the below, should all the rows above 'DIM_1' be deleted, or just the row below 'Flatness'?
Mark
Bearing in mind clarification in msg#3, have tested md's solution and it works fine in xl2007 too. Mine will delete the wrong stuff.
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
hi
thanks this is working pefectly
can please explain to me how you macro is working line by line
please it is very important to me
thanks
Originally Posted by mdmackillop
Here are some links that I have found helpful reference Regular Expressions. I personally owe a big thanks to Pedro (pgc01) at mrexcel for his long suffering patience in explaining the basics.
http://msdn.microsoft.com/en-us/libr...1x(VS.85).aspx
http://www.aivosto.com/vbtips/regex.html
http://www.regular-expressions.info/tutorial.html
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
i need to to some studying and fast
myibe you can give me a link to a good book for me print out
thanks for all you help
i never forget
friend
thanks
Google for RegExp . There is a lot out there.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
My appreciation as well Malcom; thank you. Already added to favorites to reference :-)Originally Posted by mdmackillop
A great day to you and yours,
Mark