Insert formula using VBA

I am trying to enter the following formula in using vba but it is not working, can you help show me where i am going wrong?


Range("d2:d30000").Formula = _
        "=if(c2=""Solnsmarts2"",IF(ISNUMBER(FIND(""Created by"",f2),MID(f2,FIND(""Created by"",f2)+11,IF(ISNUMBER(FIND("" "",f2,FIND(""Created by"",f2)+11)),FIND("" "",f2,FIND(""Created by"",f2)+11),LEN(f2))-FIND(""Created by"",f2)-10),"""")),c2)"

Open in new window

bryanscott53Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Muhammad KhanManager, ITCommented:

Range("d2:d30000").Formula = _
        "=if(c2=""Solnsmarts2"",IF(ISNUMBER(FIND(""Created by"",f2)),MID(f2,FIND(""Created by"",f2)+11,IF(ISNUMBER(FIND("" "",f2,FIND(""Created by"",f2)+11)),FIND("" "",f2,FIND(""Created by"",f2)+11),LEN(f2))-FIND(""Created by"",f2)-10),""""),c2)"

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AgeOfEmpiresCommented:
Not sure exactly what you are trying to do, but upon quick inspection, one of the first things I see is an incorrect call to ISNUMBER.  It takes one parameter, yet you don't have a closing ")" after the FIND(""Created by"",f2) to close out the ISNUMBER function.  Same thing on the next call.

0
Robert SchuttSoftware EngineerCommented:
I think this is what you need (changed some arguments around)...

Range("d2:d30000").Formula = "=if(c2=""Solnsmarts2"",IF(ISNUMBER(FIND(""Created by"",f2)),MID(f2,FIND(""Created by"",f2)+11,IF(ISNUMBER(FIND("" "",f2,FIND(""Created by"",f2)+11)),FIND("" "",f2,FIND(""Created by"",f2)+11),LEN(f2)-FIND(""Created by"",f2)-10)),""""),c2)"

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Robert SchuttSoftware EngineerCommented:
it was basically what AgeOfEmpires already said, to solve it, I rewrote the formula like this (it helps if you have a text editor that can show matching brackets):

=if(
	c2="Solnsmarts2",
	IF(
		ISNUMBER(FIND("Created by",f2)),
		MID(
			f2,
			FIND("Created by",f2)+11,
			IF(
				ISNUMBER(
					FIND(
						" ",
						f2,
						FIND("Created by",f2)+11
					)
				),
				FIND(
					" ",
					f2,
					FIND("Created by",f2)+11
				),
				LEN(f2)-FIND("Created by",f2)-10
			)
		),
		""
	),
	c2
)

Open in new window

0
bryanscott53Author Commented:
excellent, spent 2 hours on trying to fix this thanks for your help
0
AgeOfEmpiresCommented:
Glad to see someone else investigates problems this way! This is exactly the way I verified the mismatch.  With those long formulas, trying to sort it out in your head isn't always fool-proof.  Putting it in a text editor (as robert_schutt and I did) will certainly help to isolate these types of problems.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.