Hey there, been struggling with finding my error for a while so I figured I'd give this a try.
Here is the code that I'm trying to run.
And this is what is stored in cell E2: ':DC1
This is a small chunk a large macro where the purpose of this section is to remove the colon from the beginning of a string. However the code does not ever enter the first section where it would remove the colon as it always displays the message box "if statement did not work".
It's a problem with the first line of the code since I've never had it display the "if statement worked" message box.
Any help is appreciated.
For anyone who attempts to help, here are some things I've already tried:
- using E2 instead of "E2"
- using Left$() instead of Left()
- removing the brackets around the if statement
- using characters other than a colon
- using cells other than E2
- removing the apostrophe from ':DC1
- solely placing a colon in cell E2
I'm sure it's something simple that I'm missing/forgetting but for the life of me I can't figure it out.
Thanks in advance.
Here is the code that I'm trying to run.
Code:
Sub test()
If (Left("E2", 1) = ":") Then
Range("E2") = Right("E2", (Len("E2") - Range("E2").Find(":", "E2", 1)))
MsgBox ("if statement worked")
Else
MsgBox ("if statement did not work")
End If
End Sub
And this is what is stored in cell E2: ':DC1
This is a small chunk a large macro where the purpose of this section is to remove the colon from the beginning of a string. However the code does not ever enter the first section where it would remove the colon as it always displays the message box "if statement did not work".
It's a problem with the first line of the code since I've never had it display the "if statement worked" message box.
Any help is appreciated.
For anyone who attempts to help, here are some things I've already tried:
- using E2 instead of "E2"
- using Left$() instead of Left()
- removing the brackets around the if statement
- using characters other than a colon
- using cells other than E2
- removing the apostrophe from ':DC1
- solely placing a colon in cell E2
I'm sure it's something simple that I'm missing/forgetting but for the life of me I can't figure it out.
Thanks in advance.