Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange Behavior With Chart Macro in Excel 2007

Status
Not open for further replies.

txmed

Programmer
Mar 23, 2006
65
US
Greetings. I've been having a problem with my Excel macro that I've built to automatically create charts. I have a rather large spreadsheet that has all kinds of data in it. When I select a cell and run my macro, the code finds the previous 6 cells for that row and then dynamically creates a chart.

My code works great on my test data. When I tried on my live data, I started getting a strange error (sometimes).

On some of the data that I attempt to create a chart, I get a "type mismatch" error when I use the statement:

Code:
  Dim pobjChart As New Chart
  Set pobjChart = Charts.Add

Again I only get this error "sometimes".

The really strange thing is that when I add a blank row anywhere into the worksheet, and then I run the macro again against the same data it works fine.

Has anyone experienced this problem before? Is Excel doing something behind the scenes that I'm not aware of?

Thanks in advance for you help.

(txmed)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top