As the title suggests, I need a macro that will automatically look at colum A (except range A1) and then delete anything that is not alphabet letters i.e. a * or other charecters. Also need to delete if more than 4 letters long.
Can you help?
Thanks in advance
Last edited by ollierice; 06-08-2011 at 05:31 AM.
try this for delate string longer then 4 characters
sub check_delete() dim r as integer r = 2'starting row do until cells(r,1).value = "" if len(cells(r,1).value) > 4 then cells(r,1).value = "" r = r +1 loop end sub
Last edited by maczaq; 06-07-2011 at 07:08 AM.
ollierice
Do you mean just keep cells with one to four letters only?
or remove numbers and symbols?Sub check_delete() Dim r As Integer r = 2 'starting row Do Until Cells(r, 1).Value = "" If Match_Keep(Cells(r, 1)) Then Cells(r, 1).Value = "" r = r + 1 Loop End Sub Function Match_Keep(Rng As Range) As Boolean Dim RegEx As Object Dim Match_Stuff Match_Stuff = Rng.Text Set RegEx = CreateObject("vbscript.regexp") With RegEx .Global = True .Pattern = "^([a-zA-Z]{1,4})$" If RegEx.Test(Match_Stuff) Then Match_Keep = False Else Match_Keep = True End If End With Set RegEx = Nothing End Function
regards pike
If the solution helped please donate here to the RSPCA
Sites worth visiting;
J&R Solutions - royUK
AJP Excel Information - Andy Pope
Spreadsheet Toolbox
VBA for smarties - snb
Thanks very much.
If you are satisfied with the solution(s) provided, please mark your thread as Solved.
How to mark a thread Solved
Go to the first post
Click edit
Click Go Advanced
Just below the word Title you will see a dropdown with the word No prefix.
Change to Solved
Click Save
regards pike
If the solution helped please donate here to the RSPCA
Sites worth visiting;
J&R Solutions - royUK
AJP Excel Information - Andy Pope
Spreadsheet Toolbox
VBA for smarties - snb
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks