Solved

Small debug Error within Excel macro

Posted on 2014-10-23
8
105 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 32

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 32

Expert Comment

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

Rob
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
: Microsoft Office Collaborate for free and online versions of Microsoft  Word, Excel, Powerpoint, OneNote, Onedrive , Email, Calendar etc. In short we can say that Microsoft office is a suite of servers, applications and services developed by  Micr…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

20 Experts available now in Live!

Get 1:1 Help Now