Arrays Excel VBA数组的数组

Arrays Excel VBA数组的数组,arrays,vba,date,excel,Arrays,Vba,Date,Excel,我试图在Excel的宏中创建一个数组数组。这是我的问题。。。我正在创建一个年度日历,希望突出显示日历中的日期 我在工作表中有一系列日期。这些日期可以是我想记住的任何类型的日期,等等。我把它们读入日历,然后创建日历,使这些不同的日期具有不同的背景色 在我有限的思考中,我会把它们读进去,按月份将它们分组,然后列出与该月份相关的日期 9 -> 24, 30 1 -> 20, 1 4 -> 5 这是我到目前为止所拥有的 'Set Variables Dim ImportantDays

我试图在Excel的宏中创建一个数组数组。这是我的问题。。。我正在创建一个年度日历,希望突出显示日历中的日期

我在工作表中有一系列日期。这些日期可以是我想记住的任何类型的日期,等等。我把它们读入日历,然后创建日历,使这些不同的日期具有不同的背景色

在我有限的思考中,我会把它们读进去,按月份将它们分组,然后列出与该月份相关的日期

9 -> 24, 30
1 -> 20, 1
4 -> 5
这是我到目前为止所拥有的

'Set Variables
Dim ImportantDays As Variant
Dim id As Integer
Dim tempSplitDateArray() As Integer

'Grab the dates from the entered WorkSheet
ImportantDays = Worksheets("MainData").Range("E4:E19")

'Loop through the dates entered
For id = LBound(ImportantDays, 1) To UBound(ImportantDays, 1)
    If ImportantDays(id, 1) <> "" Then
        tempSplitDateArray() = Split(ImportantDays(id, 1), "/")
        '--I now have tempSplitDateArray(0) = month
        '--tempSplitDateArray(1) = day

        '------------------------------------
        '-- Not sure of my next step here
        '------------------------------------
    End If
Next id
理想情况下,我会将9月份的所有月份都储存在每月9日或类似的时间,但我对

如何在存储它们时进行跟踪? 在创建特定月份时,如何访问和循环这些值?
有什么想法吗?

如果我理解正确,我认为这个选项适合你

Sub test()
Dim id&, z&, oCell As Range, Key, MKey
Dim I_Month As Object: Set I_Month = CreateObject("Scripting.Dictionary")
Dim I_Day As Object: Set I_Day = CreateObject("Scripting.Dictionary")
Dim Cnt As Object: Set Cnt = CreateObject("Scripting.Dictionary")
Dim Month_count As Object: Set Month_count = CreateObject("Scripting.Dictionary")
id = 1
'Grab the dates from the entered WorkSheet
For Each oCell In Worksheets("MainData").Range("E4:E19")
    I_Month.Add id, Month(oCell.Value)
    I_Day.Add id, Day(oCell.Value)
    id = id + 1
Next
id = 12
z = 0
While id <> 0
    For Each Key In I_Month
        If I_Month(Key) = id Then z = z + 1
    Next
    Cnt.Add id, z
    id = id - 1: z = 0
Wend
For Each Key In I_Month
        For Each MKey In Cnt
            If MKey = I_Month(Key) Then
                id = Cnt(MKey)
                Exit For
            End If
        Next
    Month_count.Add Key, id
Next
For Each Key In I_Month
   Debug.Print Key, I_Month(Key), I_Day(Key), Month_count(Key)
Next
End Sub

我不明白你需要什么一个二维数组,或者数组的数组。日期是一个单数值,您只需要一个包含日历日的数组和一个包含重要日期的数组。我在这里遗漏了什么?我正在尝试创建一个简单的数组,用于保存特定月份的所有日期。这意味着我需要一个与某个值关联的天数数组,让我知道是哪个月。谢谢您的帮助。我能够使用它,并改变一些东西,使其工作。我发现VBA对完整VB所能提供的功能非常有限。
Dim monthlyDates(12, 16) As Variant
Sub test()
Dim id&, z&, oCell As Range, Key, MKey
Dim I_Month As Object: Set I_Month = CreateObject("Scripting.Dictionary")
Dim I_Day As Object: Set I_Day = CreateObject("Scripting.Dictionary")
Dim Cnt As Object: Set Cnt = CreateObject("Scripting.Dictionary")
Dim Month_count As Object: Set Month_count = CreateObject("Scripting.Dictionary")
id = 1
'Grab the dates from the entered WorkSheet
For Each oCell In Worksheets("MainData").Range("E4:E19")
    I_Month.Add id, Month(oCell.Value)
    I_Day.Add id, Day(oCell.Value)
    id = id + 1
Next
id = 12
z = 0
While id <> 0
    For Each Key In I_Month
        If I_Month(Key) = id Then z = z + 1
    Next
    Cnt.Add id, z
    id = id - 1: z = 0
Wend
For Each Key In I_Month
        For Each MKey In Cnt
            If MKey = I_Month(Key) Then
                id = Cnt(MKey)
                Exit For
            End If
        Next
    Month_count.Add Key, id
Next
For Each Key In I_Month
   Debug.Print Key, I_Month(Key), I_Day(Key), Month_count(Key)
Next
End Sub
 Key           Month         Day           Count of the Month iteration
 1             6             22            4 
 2             10            24            2 
 3             6             15            4 
 4             10            28            2 
 5             1             14            3 
 6             1             9             3 
 7             11            15            1 
 8             1             24            3 
 9             6             2             4 
 10            3             21            1 
 11            12            26            2 
 12            5             25            2 
 13            2             23            1 
 14            12            7             2 
 15            5             31            2 
 16            6             5             4