VBA project : Graphics with variable data sources
I just learnt how to use VBA, I'm beginner!
I try for 2 days to do something and id still doesn't work so I think I need some help... I don't understand what is wrong with my code.
I'm sorry I couldn't attach the excel document but it's too big so I took photos...
and here are some explanations of what I'd like to obtain :
I have two sheets:
-sheet 1 : data source
-sheet 2 : Graphics related to these data sources
Boths of the sheets are a 12x12 matrix, for which each element is a column of 180 values (it's a result as function of the angle)
So I have a total amount of 12x12x180 values.
For each column of 180 values from sheet one, I'd like in sheet 2 an area graphic with the value as function of the angle, which would be automatically created at the right place with the right dimensions (see as exemple the first graphic in sheet 2).
I started to write the macro "Graphe" that firstly should create and place the graphics (no dimensions yet), but it doesn't work and i don't understand why... :
' Graphe Macro
Dim i As Integer
Dim j As Integer
For i = 1 To 12
For j = 1 To 12
'begin of the column to select as source for y axis of the graphic
Dim X As Variant
X = "5 + (j - 1) * 186" 'line
Dim Y As Variant
Y = "1 + 3 * i" ' column
'End of the column to select as source for y axis of the graphic
Dim U As Variant
U = "5 + (j - 1) * 186 + 180" 'line
Dim V As Variant
V = "1 + 3 * i" ' column
Dim Graphic As Chart, Values As Range
Cells(X, Y).Select 'So that the graphik is created at the right place
Set Values = Worksheets("Sheet1").Range(Cells(X, Y), Cells(U, V))
Set Graphic = ThisWorkbook.Charts.Add
Graphic.ChartType = xlArea
Graphic.SetSourceData Values, Range("B5,B185") 'its always the same (0 to 180) so it doesn't need to vary with i and j
Can someone help me with this thing?
|Capture d’écran 2012-12-05 à 12.17.50.png||200.72 KB|
|Capture d’écran 2012-12-05 à 12.18.52.png||39.06 KB|