私は辞書を初期化しようとしています。私は3、4、10などが必要であるかどうかはわかりません。だから私は、次のことを試してみました:未知数の変数を初期化しようとしています
dim wb1 as workbook
set wb1 = ThisWorkbook
dim strdict as new scripting.dictionary
For c = 1 To 65536 'for all rows
If strdict.Exists(wb1.Sheets(1).Cells(1, 4)) Then
'if that string has already been logged ie this is not the first pass of the current string, log it
strdict(wb1.Sheets(1).Cells(1, 4)) = strdict(wb1.Sheets(1).Cells(1, 4)) + 1
Else
strdict.Add wb1.Sheets(1).Cells(1, 4), 1
'if that string is not present, add it to the dictionary
dim left(wb1.Sheets(1).cells(1,4), 3) & "log" as Scripting.dictionary
End If
Next c
私は
dim left(wb1.Sheets(1).cells(1,4), 3) & "log" as Scripting.dictionary
が機能しなかったことを驚きましたが、私はと思っています何を達成する方法があると言うことはできません?それともvbaができないものですか?
辞書の辞書に基づいて更新? –
私はそれを考えましたが、まだそれらの名前を付ける必要はありませんか?彼らは名前を共有することはできませんが、別の名前を付ける方法はわかりません。セルデータは明らかな選択肢でしたが、それを使用するのは好きではないようです。 –
とにかく一意の変数名が必要です。別のアプローチは、異なるセルに対して異なるキーを有する単一の辞書を使用することである。タグ付きキーを取得するには、セルアドレスをキーと結合します。別の注記では、「For c = 1 to 65536」は問題があるようです。あなたは本当に65000行のデータを持っていますか? –