0

Goodmorning from Holland,

I'm just n00bing around VBA, and keep bumping in to said compilation error as seen in this screenshot; Screenshot I would like to see this solved, but i want to learn how to kill these horrible errors. What is my mistake?

3
  • Edited it, so the error shows in the screen. Commented Dec 2, 2015 at 10:25
  • Just count your Ifs and your End Ifs and you will see it. Commented Dec 2, 2015 at 10:30
  • See Why Not Images of Code and Sample Data. Commented Dec 2, 2015 at 11:11

2 Answers 2

2

As the error message is telling you, you are missing one End If-Statement: You are opening three If-Cases, but close only two of them. (I guess you want to put the missing one before the line saying If not Rng Is Nothing Then, thus closing the statement If Trim(FindString) <> "" Then)

For the future: Proper indentation of your code will help you spot errors like this easily!

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for making the way to think about indentation clear to me. Second good answer on one of my questions, hero.
@RobExcel you're welcome :-) One more thing: Please try to add Code in writing rather than as screenshot. This makes it easier for us to try around with it without having to type everything from scratch!
2

Your "If Not Rng Is Nothing Then" is missing an "End If"

It should be more obvious if you indent correctly your code.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.