-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEXCEL_CHART_DELETE_LIBR.bas
executable file
·53 lines (41 loc) · 1.92 KB
/
EXCEL_CHART_DELETE_LIBR.bas
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
Attribute VB_Name = "EXCEL_CHART_DELETE_LIBR"
'--------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------
Option Explicit 'Requires that all variables to be declared explicitly.
Option Base 1 'The "Option Base" statement allows to specify 0 or 1 as the
'default first index of arrays.
'--------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------
'************************************************************************************
'************************************************************************************
'FUNCTION : EXCEL_CHARTS_DELETE_FUNC
'DESCRIPTION :
'LIBRARY : EXCEL_CHART
'GROUP : DELETE
'ID : 001
'AUTHOR : RAFAEL NICOLAS FERMIN COTA
'************************************************************************************
'************************************************************************************
Function EXCEL_CHARTS_DELETE_FUNC(ByRef REF_VECTOR As Variant, _
Optional ByRef SRC_WSHEET As Excel.Worksheet)
Dim i As Long
Dim CHART_OBJ As Excel.Chart
Dim MATCH_FLAG As Boolean
On Error GoTo ERROR_LABEL
If SRC_WSHEET Is Nothing Then: Set SRC_WSHEET = ActiveSheet
EXCEL_CHARTS_DELETE_FUNC = False
For Each CHART_OBJ In SRC_WSHEET.ChartObjects
MATCH_FLAG = False
For i = LBound(REF_VECTOR) To UBound(REF_VECTOR)
If REF_VECTOR(i) = CHART_OBJ.name Then
MATCH_FLAG = True
Exit For
End If
Next i
If MATCH_FLAG = False Then: CHART_OBJ.Delete
Next CHART_OBJ
EXCEL_CHARTS_DELETE_FUNC = True
Exit Function
ERROR_LABEL:
EXCEL_CHARTS_DELETE_FUNC = False
End Function