Link to home
Start Free TrialLog in
Avatar of michaelm702
michaelm702

asked on

excel macro needed

I have a column in a spreadsheet in which the cells will have value one of the following :
m = male,f = female
m = male^f = female
Note that there is space after and before equal to sign.
I need a macro which will check for all the cells in the column so that there is space after and before equal to sign. If a space is not there then that cell should be colured in red.
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Trusting that you have two equal signs in each cell:

    Dim v
    Dim r As Integer
   
    Const c = 1
    For r = 1 To ActiveSheet.UsedRange.Cells.Count
        v = Split(ActiveSheet.UsedRange.Cells(r, c), " = ")
        If UBound(v) < 2 Then
            ActiveSheet.UsedRange.Cells(r, c).Interior.ColorIndex = 3
        End If
    Next r
Avatar of michaelm702
michaelm702

ASKER

Each Cell does not have only two equal to signs there must be atleast one and any number greater than one. We should also check that each cell in that column has an equal to present aso.
ASKER CERTIFIED SOLUTION
Avatar of byundt
byundt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial