Palerock68
New Member
- Joined
- Apr 20, 2018
- Messages
- 6
So, I want Excel to go through each cell in the column I and if the length of the cell contents is more than zero, go through the next lines and change the content accordingly... but if the content is not listed and still the length of the current content is more than Zero... just change it to 3.2. But if the length of the content is zero, just go to next cell.
But I cannot get any of the combinations to work correctly.
This leaves the cell untouched, even if the length is more than zero, but the character found is not listed:
For f = 7 To LastRow
If Len(Cells(f, 9)) > 0 Then
If Cells(f, 9) = 2 Then Cells(f, 9) = "'3.2"
If Cells(f, 9) = 1 Then Cells(f, 9) = "'3.1"
If Cells(f, 9) = "T" Then Cells(f, 9) = "'3.1"
If Cells(f, 9) = "-" Then Cells(f, 9).ClearContents
If Cells(f, 9) = Chr(42) Then Cells(f, 9) = Chr(42)
Else
If Len(Cells(f, 9)) > 0 Then Cells(f, 9) = "'3.2"
End If
Next f
And the following fills all cells with 3.2, regardless of the cells content length:
For f = 7 To LastRow
If Len(Cells(f, 9)) > 0 Then
If Cells(f, 9) = 2 Then Cells(f, 9) = "'3.2"
If Cells(f, 9) = 1 Then Cells(f, 9) = "'3.1"
If Cells(f, 9) = "T" Then Cells(f, 9) = "'3.1"
If Cells(f, 9) = "-" Then Cells(f, 9).ClearContents
If Cells(f, 9) = Chr(42) Then Cells(f, 9) = Chr(42)
Else
Cells(f, 9) = "'3.2"
End If
Next f
And the following works like the first one, it leaves the not listed characters untouched:
For f = 7 To LastRow
If Len(Cells(f, 9)) > 0 Then
If Cells(f, 9) = 2 Then Cells(f, 9) = "'3.2"
If Cells(f, 9) = 1 Then Cells(f, 9) = "'3.1"
If Cells(f, 9) = "T" Then Cells(f, 9) = "'3.1"
If Cells(f, 9) = "-" Then Cells(f, 9).ClearContents
If Cells(f, 9) = Chr(42) Then Cells(f, 9) = Chr(42)
ElseIf Len(Cells(f, 9)) > 0 Then Cells(f, 9) = "'3.2"
End If
Next f
Could anybody help a bit?
But I cannot get any of the combinations to work correctly.
This leaves the cell untouched, even if the length is more than zero, but the character found is not listed:
For f = 7 To LastRow
If Len(Cells(f, 9)) > 0 Then
If Cells(f, 9) = 2 Then Cells(f, 9) = "'3.2"
If Cells(f, 9) = 1 Then Cells(f, 9) = "'3.1"
If Cells(f, 9) = "T" Then Cells(f, 9) = "'3.1"
If Cells(f, 9) = "-" Then Cells(f, 9).ClearContents
If Cells(f, 9) = Chr(42) Then Cells(f, 9) = Chr(42)
Else
If Len(Cells(f, 9)) > 0 Then Cells(f, 9) = "'3.2"
End If
Next f
And the following fills all cells with 3.2, regardless of the cells content length:
For f = 7 To LastRow
If Len(Cells(f, 9)) > 0 Then
If Cells(f, 9) = 2 Then Cells(f, 9) = "'3.2"
If Cells(f, 9) = 1 Then Cells(f, 9) = "'3.1"
If Cells(f, 9) = "T" Then Cells(f, 9) = "'3.1"
If Cells(f, 9) = "-" Then Cells(f, 9).ClearContents
If Cells(f, 9) = Chr(42) Then Cells(f, 9) = Chr(42)
Else
Cells(f, 9) = "'3.2"
End If
Next f
And the following works like the first one, it leaves the not listed characters untouched:
For f = 7 To LastRow
If Len(Cells(f, 9)) > 0 Then
If Cells(f, 9) = 2 Then Cells(f, 9) = "'3.2"
If Cells(f, 9) = 1 Then Cells(f, 9) = "'3.1"
If Cells(f, 9) = "T" Then Cells(f, 9) = "'3.1"
If Cells(f, 9) = "-" Then Cells(f, 9).ClearContents
If Cells(f, 9) = Chr(42) Then Cells(f, 9) = Chr(42)
ElseIf Len(Cells(f, 9)) > 0 Then Cells(f, 9) = "'3.2"
End If
Next f
Could anybody help a bit?