Solved

Small debug Error within Excel macro

Posted on 2014-10-23
8
108 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 33

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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
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 …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

861 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