?
Solved

Small debug Error within Excel macro

Posted on 2014-10-23
8
Medium Priority
?
128 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 36

Accepted Solution

by:
Kimputer earned 1000 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 33

Assisted Solution

by:Rob Henson
Rob Henson earned 400 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 33

Expert Comment

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

Rob
0
 

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 600 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

752 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