VBA error on form code

I had been running a form code that enters data into a spreadsheet.
It was working accurately, until I added three txtbox & three labels, now I get an error on line below, which enters a formula into column A on whatever sheet it is on.

Again, this was working properly, so the code is good, just adding the Discount, ED & Min Reduction were added now the formula below is an error.
I will attach the project if this will help.


       .Range("A" & lngNextRow).Formula = "=INDIRECT(""AK""&ROW())&IF(INDIRECT(""B""&ROW())<>"""","" ("","""")&INDIRECT(""B""&ROW())&IF(INDIRECT(""B""&ROW())<>"""",""-"","""")&INDIRECT(""C""&ROW())&IF(INDIRECT(""B""&ROW())<>"""","") "","""")&"" ""&INDIRECT(""E""&ROW())&"" ""&INDIRECT(""AM""&ROW())&"" ""&INDIRECT(""AL""&ROW())"""

Open in new window

What-if-scenario-v4-test-form.xlsm
Euro5Asked:
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.

Martin LissOlder than dirtCommented:
There's nothing in that line that refers to anything on a form which is where I assume the new textboxes and labels are.

Have you tried entering the formula manually? If you can get it to work manually, converting it to VBA shouldn't be too hard.
0
dameyCommented:
Indirect does not handle active sheet or active cell

Before your call you can debug using the following
Debug.Print Application.ActiveSheet().ToString()
Debug.Print Application.ActiveCell().ToString()
//If not what you want
 Workbooks("BOOK1 XLS"). Worksheets("Sheet1 ").Activate

On that note create dynamic functions for each step of the way.
0
Euro5Author Commented:
I know, the line just enters the formula, the only relationship is that it works with the code where the other data is entered into the spreadsheet.
Yes, I have it working manually and I have it working on the old form just fine.
Three steps forward....two steps back.
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.

Martin LissOlder than dirtCommented:
Can you show the manually entered formula?
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Though I have not downloaded your large file, see if the following line works without an issue..
Range("A" & lngNextRow).Formula = "=INDIRECT(""AK""&ROW())&IF(INDIRECT(""B""&ROW())<>"""","" ("","""")&INDIRECT(""B""&ROW())&IF(INDIRECT(""B""&ROW())<>"""",""-"","""")&INDIRECT(""C""&ROW())&IF(INDIRECT(""B""&ROW())<>"""","") "","""")&"" ""&INDIRECT(""E""&ROW())&"" ""&INDIRECT(""AM""&ROW())&"" ""&INDIRECT(""AL""&ROW())"

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
Euro5Author Commented:
Manually entered

=INDIRECT("AK"&ROW())&IF(INDIRECT("B"&ROW())<>""," (","")&INDIRECT("B"&ROW())&IF(INDIRECT("B"&ROW())<>"","-","")&INDIRECT("C"&ROW())&IF(INDIRECT("B"&ROW())<>"",") ","")&" "&INDIRECT("E"&ROW())

Open in new window

0
Euro5Author Commented:
That was it!!!!  I had the .Range  instead of the usual Range
0
Martin LissOlder than dirtCommented:
Replace your VBA formula with the manual one.
1
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.