![]() |
What is wrong with this?
I want to write a function which loops through a column and creates a chart. for some reason it isnt working and it dont gives an error at all. any ideas what is wrong? ---cut--- Sub DiagrammErstellen() Dim oldi oldi = 2 For i = 2 To Application.WorksheetFunction.CountA("A:A") Step 10 Charts.Add ActiveChart.SetSourceData Source:=Sheets("Tabelle1").Range(oldi + ":" + i + "," + oldi + ":" + i + "") 'ActiveChart.SetSourceData Source:=Sheets("Tabelle1").Range("A2:A7,B2:B7") ActiveChart.Location Whe=xlLocationAsNewSheet Charts.Add oldi = i Next End Sub ---cut--- -- A.S. ------------------------------------------------------------------------ A.S.'s Profile: http://www.excelforum.com/member.php...o&userid=26003 View this thread: http://www.excelforum.com/showthread...hreadid=393646 |
What is wrong with this?
For starters, Application.WorksheetFunction.CountA("A:A") is counting the
literal string "A:A", not the RANGE! Try Application.WorksheetFunction.CountA(Range("A:A") ) Next, this assumes that a worksheet is active, and after 1st time thru the loop, this is no longer true. Perhaps you need Application.WorksheetFunction.CountA(Sheets(1).Ran ge("A:A") ) .... just for starters. Bob Umlas Excel MVP "A.S." wrote in message ... I want to write a function which loops through a column and creates a chart. for some reason it isnt working and it dont gives an error at all. any ideas what is wrong? ---cut--- Sub DiagrammErstellen() Dim oldi oldi = 2 For i = 2 To Application.WorksheetFunction.CountA("A:A") Step 10 Charts.Add ActiveChart.SetSourceData Source:=Sheets("Tabelle1").Range(oldi + ":" + i + "," + oldi + ":" + i + "") 'ActiveChart.SetSourceData Source:=Sheets("Tabelle1").Range("A2:A7,B2:B7") ActiveChart.Location Whe=xlLocationAsNewSheet Charts.Add oldi = i Next End Sub ---cut--- -- A.S. ------------------------------------------------------------------------ A.S.'s Profile: http://www.excelforum.com/member.php...o&userid=26003 View this thread: http://www.excelforum.com/showthread...hreadid=393646 |
All times are GMT +1. The time now is 08:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com