I have created a macro to highlight the cells in my file if they exceed 55chars. (So I can decide how to abbr the cells myself) If the cell is fine(before or after I fix it), then the macro sets the cell back to no color.
The macro actually works, but I have two issues.
1) I can't seem to make the macro work for each cell in a selection. It seems to count the characters of all cells and highlights the whole block, including blank cells.
2) I'm not sure how to avoid checking blank cells in the first place to speed up the macro.
Sub over55color()
'
' over55color Macro - will turn a row yellow if over 55 characters, will turn it back to white if the cell is fixed and macro runs again
Dim myVariable As Integer
myVariablecount = Len(ActiveCell)
If myVariablecount > 55 Then
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Else
Selection.Interior.ColorIndex = xlNone
End If
End Sub
but this doesn't seem to work:
For Each cell In Selection
myVariablecount = Len(ActiveCell)
If myVariablecount > 55 Then
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Else
Selection.Interior.ColorIndex = xlNone
End If
Next cell
End Sub
--Metahari
The macro actually works, but I have two issues.
1) I can't seem to make the macro work for each cell in a selection. It seems to count the characters of all cells and highlights the whole block, including blank cells.
2) I'm not sure how to avoid checking blank cells in the first place to speed up the macro.
Sub over55color()
'
' over55color Macro - will turn a row yellow if over 55 characters, will turn it back to white if the cell is fixed and macro runs again
Dim myVariable As Integer
myVariablecount = Len(ActiveCell)
If myVariablecount > 55 Then
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Else
Selection.Interior.ColorIndex = xlNone
End If
End Sub
but this doesn't seem to work:
For Each cell In Selection
myVariablecount = Len(ActiveCell)
If myVariablecount > 55 Then
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Else
Selection.Interior.ColorIndex = xlNone
End If
Next cell
End Sub
--Metahari