Code:Sub MakeData() Dim rngMinPoints As Range Dim rngMaxPoints As Range Dim rngMinDollars As Range Dim rngMaxDollars As Range Dim rngMinPay As Range Dim rngMaxPay As Range Dim rngOutput As Range Dim lngNGrades As Long Dim lngIndex As Long With Worksheets("Pay Grades") Set rngMinPay = .Range("C17") Set rngMaxPay = .Range("F17") lngNGrades = .Range("D16") Set rngMinPoints = .Range("B20").Resize(lngNGrades, 1) Set rngMaxPoints = rngMinPoints.Offset(0, 2) Set rngMinDollars = rngMinPoints.Offset(0, 4) Set rngMaxDollars = rngMinPoints.Offset(0, 5) End With Set rngOutput = Worksheets("BoxesScreen7").Range("A1") rngOutput.Offset(0, 0).Formula = "='" & rngMinPay.Parent.Name & "'!" & rngMinPay.Address rngOutput.Offset(1, 0).Formula = "='" & rngMinPay.Parent.Name & "'!" & rngMinPay.Address rngOutput.Offset(1, 1).Formula = "='" & rngMinDollars.Parent.Name & "'!" & rngMinDollars.Cells(1, 1).Address rngOutput.Offset(1, 2).Formula = "='" & rngMaxDollars.Parent.Name & "'!" & rngMaxDollars.Cells(1, 1).Address For lngIndex = 1 To lngNGrades rngOutput.Offset(lngIndex + 1, 0).Formula = "='" & rngMinPoints.Parent.Name & "'!" & rngMinPoints.Cells(lngIndex + 1, 1).Address rngOutput.Offset(lngIndex + 1, 1).Formula = "='" & rngMinDollars.Parent.Name & "'!" & rngMinDollars.Cells(lngIndex, 1).Address rngOutput.Offset(lngIndex + 1, 2).Formula = "='" & rngMaxDollars.Parent.Name & "'!" & rngMaxDollars.Cells(lngIndex + 1, 1).Address Next rngOutput.Offset(lngNGrades + 1, 0).Formula = "='" & rngMaxPay.Parent.Name & "'!" & rngMaxPay.Address rngOutput.Offset(lngNGrades + 2, 0).Formula = "='" & rngMaxPay.Parent.Name & "'!" & rngMaxPay.Address rngOutput.Offset(lngNGrades + 1, 2).Formula = "='" & rngMaxDollars.Parent.Name & "'!" & rngMaxDollars.Cells(lngNGrades, 1).Address rngOutput.Offset(1, 3).Resize(lngNGrades + 1, 1).FormulaR1C1 = "=RC[-1]-RC[-2]" rngOutput.Offset(1, 4).Resize(lngNGrades + 1, 1).FormulaR1C1 = "=RC[-4]-R[-1]C[-4]" rngOutput.Offset(1, 5).Resize(lngNGrades + 1, 1).FormulaR1C1 = "=R[1]C[-5]-RC[-5]" End Sub
Thanks Andy I will try it out.
Hi Andy, your solution worked. Thanks a lot!
- Ravi
Hi Andy:
In the worksheet you posted in this thread (670622.xls), in one instance having a value of zero in B20 seemed to display the following error:
"Run-time error '1004'
Unable to set the XValues property of the series class"
This happened only once and I was not able to replicate the issue using a zero in the referenced cell. Any thoughts? Thanks.
- Ravi
Can you post a workbook that demonstrates the problem
Hi Andy:
Here is a work sheet with the actual data that caused the run-time error. However, the error did not show up this time. It happened only once. Thanks.
- Ravi
Lets worry about it when the error does appear consistently![]()
Andy:
I have attached a screen print of the error when it happened. Thanks.
- Ravi
Last edited by ravichander; 03-20-2009 at 03:31 PM.
LOL, OK Andy. I will see if that error surfaces again. Thanks.
- Ravi
Hi Andy:
Here is a situation where the graph was not displayed but came with the same error 1004. Clicking on help said something about macros, which were already enabled to run. In some instance there were messages that said that the worksheet was read only, thus not allowing any changes to be made. This happened on laptops, one with XP, one with Vista, one with 2003 excel one
with 2007. I don't have a cue as to what might be happening here.
I have attached the referenced worksheets for your review. Thanks.
- Ravi
Last edited by ravichander; 03-20-2009 at 03:31 PM.
you passworded the VBA so I can not see anything.
It throws an error when loading the splash screen.
It also errors when deleting series, although I don't know why it's deleting series.
Looks like you need to add some general error trapping into the code to check for certain states, such as no series.
You may also encounter problems trying to manipulate chart series that have no data.
Sent to you.
I think the deletion was to ensure that only the required number of seriese were created each time.
Noticed that changing the name of the file also produces errors.
As an aside, any issues with Excel 2007 saved as a xls file on the Vista Operating System? Should I start this topic as a new thread? Thanks Andy.
- Ravi
You need to change the way you reference the chart as currently you are using a name that could change if you created another chart.
As for error when the workbook name changes that is because, again, you are using fixed names as the reference.Code:Sub ClearExistingSeriesScreen7Graph() ' ' ClearExistingSeriesScreen7Graph Macro ' ' With Sheets("Pay Grades").ChartObjects(1).Chart Do While .SeriesCollection.Count > 0 .SeriesCollection(1).Delete Loop End With End Sub
so instead of references like this
useCode:Windows("CompSoftPhaseII.XLS").Activate
Code:Thisworkbook.Activate
Thanks Andy. Is there a way of globally changing the reference from the specific workbook to ThisWorkBook.Activate?
Are there any known issues for Excel 2002-07 runing on Vista? Thanks.
- Ravi
Find/Replace
Charts are completely new in xl2007. Some of the Object model uses new properties. And in places the object model is incomplete.
I don't think you will find a detailed list it's more a case of try it and see. Then fix the problems.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks