Solved

Small debug Error within Excel macro

Posted on 2014-10-23
8
106 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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 32

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

809 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