How to get Excel "Cell" instruction to work

Leonard Gojer
Leonard Gojer used Ask the Experts™
on
I'm trying to write an Excel VBA program that will use a worksheet to debug the steps of the code so that I can see where I am programming it incorrectly. I want to use the Cell instruction to display intermediate values of the code, but it doesn't do anything and actually causes the compiler/interpreter to stop and malfunction.

Please tell me how to invoke this instruction correctly.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
The Cells object is really a collection of all cells on the worksheet.  To use it for an individual cell, specify the row and column to get back a cell object, which you can then investigate.

ActiveSheet.Cells(1,1).value = 123
Leonard GojerCAD Technician/Programmer

Author

Commented:
I tried

ActiveSheet.Cells(20 + count, 1).value = r1 ' r1 = 0.70345   count = 0

and the Cell in question did not show anything
Leonard GojerCAD Technician/Programmer

Author

Commented:
I believe that you are telling me the truth, but I also believe that there is something else wrong with my spreadsheet that is causing this bug. That's what I don't like about VBA, it doesn't handle bugs like C# does.
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Commented:
Can you show the code you have that runs your command?

Do you know how to use the debugger and stop on that line to ensure that r1 has the correct value?
Leonard GojerCAD Technician/Programmer

Author

Commented:
I even tried changing r1 to "123" and it did not work, because of other lines of code in the program that are causing the bug.

I don't want to take too much of your time, because I hired a programmer to help me with this.

Thank you for answering my question.
Leonard GojerCAD Technician/Programmer

Author

Commented:
Good job in answering me to the best of your abilities.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start Today