1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
| Private Sub CommandButton1_Click()
Dim i As Integer
Dim r1 As Range
Dim r2 As Range
Dim ranges As Range
Dim DebutX As Integer
Dim FinX As Integer
Dim j As Integer
Dim k As Integer
Dim titre As String
Dim ch As ChartObject
Dim nompage As String
nompage = Cbo_parameters.Value
'Error Messages
If cbo_debut.ListIndex > cbo_fin.ListIndex Then
MsgBox "The end Date has to be greater than the stat date"
End If
If cbo_debut.Value = "Select" Then
MsgBox "Please enter a start date"
End If
If cbo_fin.Value = "Select" Then
MsgBox "Please enter an end date"
End If
If Cbo_parameters.Value = "Select" Then
MsgBox "Please Select a Parameters"
End If
'Define i depending on Parameters selected
If Cbo_parameters.Value = "PET Coincidence Mean Value" Then
i = 2
ElseIf Cbo_parameters.Value = "PET Coincidence Variance" Then
i = 5
ElseIf Cbo_parameters.Value = "PET Singles Mean" Then
i = 8
ElseIf Cbo_parameters.Value = "PET Singles Variance" Then
i = 11
ElseIf Cbo_parameters.Value = "PET Mean Deadtime" Then
i = 14
ElseIf Cbo_parameters.Value = "PET Timing Mean" Then
i = 17
ElseIf Cbo_parameters.Value = "PET Energy Shift" Then
i = 20
ElseIf Cbo_parameters.Value = "All of the above" Then
All_Graphs.All_Graphs
Exit Sub
End If
'Define Chart title
If Cbo_parameters.Value = "PET Coincidence Mean Value" Then
titre = "PET Coincidence Mean Value"
ElseIf Cbo_parameters.Value = "PET Coincidence Variance" Then
titre = "PET Coincidence Variance"
ElseIf Cbo_parameters.Value = "PET Singles Mean" Then
titre = "PET Singles Mean"
ElseIf Cbo_parameters.Value = "PET Singles Variance" Then
titre = "PET Singles Variance"
ElseIf Cbo_parameters.Value = "PET Mean Deadtime" Then
titre = "PET Mean Deadtime"
ElseIf Cbo_parameters.Value = "PET Timing Mean" Then
titre = "PET Timing Mean"
ElseIf Cbo_parameters.Value = "PET Energy Shift" Then
titre = "PET Energy Shift"
End If
'Start & End Date selection based on the Combo Boxes
'ICI PREMIER ERREUR !!!!! car j'utilise cells
For j = 2 To 256
If CDate(Cells(1, j).Value) = CDate(cbo_debut.Value) Then
DebutX = j
End If
Next j
For k = 2 To 256
If CDate(Cells(1, k).Value) = CDate(cbo_fin.Value) Then
FinX = k
End If
Next
'Chart Range Definiton
'Erreur Majeur ici !!!!
Set r1 = Sheets("Data").Range(Cells(1, DebutX), Cells(1, FinX))
Set r2 = Sheets("Data").Range(Cells(i, DebutX), Cells(i + 2, FinX))
Set ranges = Union(r1, r2)
'Chart Creation
Charts.Add
'Chart options
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=ranges, PlotBy:= _
xlRows
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:=nompage
ActiveChart.Axes(xlCategory, xlPrimary).HasTitle = False
ActiveChart.Axes(xlValue, xlPrimary).HasTitle = False
ActiveChart.HasAxis(xlCategory, xlPrimary) = True
ActiveChart.HasAxis(xlValue, xlPrimary) = True
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale
'Chart Series & Title Names
ActiveChart.SeriesCollection(1).Name = "Mean Value"
ActiveChart.SeriesCollection(2).Name = "Min"
ActiveChart.SeriesCollection(3).Name = "Max"
ActiveChart.HasTitle = True
ActiveChart.ChartTitle.Characters.Text = titre
'X axis layout
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
ActiveChart.Axes(xlCategory).Select
Selection.TickLabels.NumberFormat = "mm/dd/yyyy"
cbo_debut.Clear
Cbo_parameters.Clear
cbo_fin.Clear
Unload Alliance_Form
End Sub
Private Sub Label5_Click()
End Sub
Private Sub UserForm_Activate()
Dim X As Integer
Dim Y As Integer
'Combo Boxes filling
For X = 2 To 256
If Cells(1, X).Value = "" Then
Else
cbo_debut.AddItem Format(Sheets("Data").Cells(1, X), "mm/dd/yyyy")
End If
Next X
For X = 2 To 256
If Cells(1, X).Value = "" Then
Else
cbo_fin.AddItem Format(Sheets("Data").Cells(1, X), "mm/dd/yyyy")
End If
Next X
With Cbo_parameters
.AddItem "PET Coincidence Mean Value"
.AddItem "PET Coincidence Variance"
.AddItem "PET Singles Mean"
.AddItem "PET Singles Variance"
.AddItem "PET Mean Deadtime"
.AddItem "PET Timing Mean"
.AddItem "PET Energy Shift"
.AddItem "All of the above"
End With
End Sub |
Partager