Dear Expert,
I am a newbie to VBA and wanted a bit of code to help me out with some excel files.
It nearly works. It processes and updates the 1st worksheet perfectly but does not process any other worksheets and I have no idea why!
My excel file has 4 columns and lots of worksheets (the layout is the same across all worksheets) :-
Column A - Contains a text description
Column B - Contains the =Len(A1) to give me the length of the string
Column C - Contains a French version of the English text in column A
Column D - Contains the =Len(C1) to give me the length of the French string
What I am trying to achieve is to compare the length of the French strings against the length of the English strings. If the French string is longer than the English then highlight the cell in Column D that is longer in red.
If anyone can help me workout what is wrong that would be great.
The code is as follows :-
Cheers
Madgik
I am a newbie to VBA and wanted a bit of code to help me out with some excel files.
It nearly works. It processes and updates the 1st worksheet perfectly but does not process any other worksheets and I have no idea why!
My excel file has 4 columns and lots of worksheets (the layout is the same across all worksheets) :-
Column A - Contains a text description
Column B - Contains the =Len(A1) to give me the length of the string
Column C - Contains a French version of the English text in column A
Column D - Contains the =Len(C1) to give me the length of the French string
What I am trying to achieve is to compare the length of the French strings against the length of the English strings. If the French string is longer than the English then highlight the cell in Column D that is longer in red.
If anyone can help me workout what is wrong that would be great.
The code is as follows :-
Code:
Private Sub CommandButton1_Click()
Dim trans_len As Range
Dim Cell As Range
Dim I As Integer
WS_Count = ActiveWorkbook.Worksheets.Count
For I = 1 To ActiveWorkbook.Worksheets.Count
Set currentsheet = ActiveWorkbook.Worksheets(I)
Worksheets(I).Activate
Set trans_len = Range("D2:D50")
For Each Cell In trans_len
If Cell.Value > Cell.Offset(, -2).Value Then
Cell.Interior.ColorIndex = 46
End If
Next
MsgBox ActiveWorkbook.Worksheets(I).Name
Next I
MsgBox "Finished", vbInformation
End Sub
Cheers
Madgik