Hi!
I am currently writing a macro for Excel and I have hit a problem.
Here is my working Macro code.
Sub dialight()
Range("B1").Select
ActiveCell.Offset(1, 0).Select
Do While ActiveCell.Value > ""
If ActiveCell.Value = "DIALIGHT" Then
ActiveCell.Offset(0, -1).Select
ActiveCell.Value = ActiveCell.Value + "F"
ActiveCell.Offset(1, 1).Select
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
End Sub
This works perfectly but the problem I have is if someone runs the
Macro twice, the ActiveCell.value will end of having 2 Fs at the end of
it which will cause huge problems further down the line.
How can I can check to see if the ActiveCell.Value already has an F at
the end of it?
Thanks,
Owain.
Robert Bruce - 06 Dec 2006 13:17 GMT
Roedd <<owain@tractionkiting.co.uk>> wedi ysgrifennu:
See my edit inline:
> Hi!
> I am currently writing a macro for Excel and I have hit a problem.
[quoted text clipped - 7 lines]
> If ActiveCell.Value = "DIALIGHT" Then
> ActiveCell.Offset(0, -1).Select
' Check for empty cell
If IsEmpty(ActiveCell) Then
ActiveCell.Value = "F"
Else
If Not Right(ActiveCell.Value, 1) = "F" Then
ActiveCell.Value = ActiveCell.Value + "F"
End If
End If
> ActiveCell.Offset(1, 1).Select
> Else
[quoted text clipped - 12 lines]
> Thanks,
> Owain.
Rob