Hello,
I get an error in the following line (at times):
rowTotal = ActiveSheet.UsedRange.Rows.count --> run-time error 91 Object variable or with block variable not set.
Also, I am creating a bar graph based on data in on of the sheets in my Excel Workbook.
When I first run the script, the graph has one bar and the x and y axis data are reversed. When I re-run it, it graphs correctly. I'm not quite sure why this is occuring.
With oChart
.ChartType = xlColumnClustered
.HasTitle = True
.SetSourceData Source:=Sheets("Sheet2").Range("B1:B148"), PlotBy:= _
xlColumns 'data source
.SeriesCollection(1).XValues = Sheets("Sheet2").Range("A1:A148") 'naming the x-axis
.ChartTitle.Characters.Text = "QTP License Usage 2009"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Date (2009)" 'x axis title
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Number of Users" 'y axis title
With .Parent 'location of Top and Left of chart
.Top = Range("F9").Top
.Left = Range("F9").Left
.Name = "Chart1"
End With
End With
-VBA to create a graph in excel.
Thanks in advance.
Configuration: Windows XP Professional Internet Explorer 7.0
RowTotal is an integer. I'm just trying to figure out the number of rows of data in the sheet.
|