Solved

Small debug Error within Excel macro

Posted on 2014-10-23
8
102 Views
Last Modified: 2014-10-23
EE Pros,

I'm trying to reset a group of cells and repopulate them with a formula.  I get a simple debug error.  Can you give me some advice on how to write this Macro correctly?  Here is a picture of what I'm experiencing.

Thank you in advance,

B.
C--Data-Temp-Debug-Error.jpg
0
Comment
Question by:Bright01
8 Comments
 
LVL 35

Accepted Solution

by:
Kimputer earned 250 total points
ID: 40399012
It should be
.Range("b5").Formula =

Also what comes after it INSIDE the most outside quotes, if inside needs quotes, double quotes will turn into one quote.

If formula is
=IF(TRUE,"TRUE", "FALSE")

your code turn into
.Range("b5").Formula = ="IF(TRUE,""TRUE"", ""FALSE"")"
0
 
LVL 31

Assisted Solution

by:Rob Henson
Rob Henson earned 100 total points
ID: 40399129
Also, rather than populating each cell individually, you can do the formula for B5 then select B5:B14 and use the Selection.FillDown command to populate the others.

Thanks
Rob H
0
 

Author Comment

by:Bright01
ID: 40399164
How would I use the Selection.FillDown command when the formula changes?

Thank you both!

B.
0
 
LVL 31

Expert Comment

by:Rob Henson
ID: 40399183
The subsequent formulas will change automatically as they have relative references.

Rob
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:Bright01
ID: 40399261
I'm still getting an error on the original code.  

Let me explain, the formula;

The formula is =If(Validation_DB!G800=0,"",Validation_DB!G800)"

If there is a -0- in cell G800, then leave the cell with the formula in it as empty.  Otherwise, put in the value from G800.

As I use the sheet, these formulas get reprioritized.  So, I'm trying to Reset them.  

But even when I use;  

.Range("b5").formula = "=If(Validation_DB!G800=0,"",Validation_DB!G800)"

I get a debug error.

B.
0
 

Author Comment

by:Bright01
ID: 40399312
OK.... so I've played around with this and the problem is the requirement I have to have a blank within the original formula.  So the problem is .Range("b5").formula = "=If(Validation_DB!G800=0,"",Validation_DB!G800)" in the "".  If I leave it blank, it produces a 0 and not a blank.........  so .Range("b5").formula = "=If(Validation_DB!G800=0, ,Validation_DB!G800)" , it produces a -0- not a blank.

How do I get it to respect the formula's ability to get a blank in the formula?

B.
0
 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 150 total points
ID: 40399534
(Not for points)

As Kimputer said originally, you need to double up quotes inside the quoted formula string:

.Range("b5").formula = "=If(Validation_DB!G800=0,"""",Validation_DB!G800)"

Open in new window

0
 

Author Closing Comment

by:Bright01
ID: 40399594
Great help and teamwork!!!!   Thank you all!   Bright01
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now