我正在尝试用一些变量编写一个宏。特别是工作表名称。几乎每次我必须在宏中找到正确的工作表名称,因此工作表名称来自单元格值。但是将变量引用到另一个变量会产生错误。
在下方,您可以看到代码的分配部分。我对任何建议持开放态度。
非常感谢你..
Dim pLastRow As Long
Dim p As Integer
pLastRow = WorksheetFunction.Max(Worksheets(WS_All).Range("AA22:AA1100"))
pLastRow2 = pLastRow + 21
For p = 22 To pLastRow2
If Cells(p, 26).Value = "" Then
WS_1 = Worksheets(WS_All).Cells(p, 16).Value
WS_2 = Worksheets(WS_All).Cells(p, 19).Value
WS_3 = Worksheets(WS_All).Cells(p, 22).Value
End If
Dim j As Long
For j = 1 To 3
Dim j_WS As Variant
j_WS = "WS_" & j
MsgBox Worksheets(j_WS).Cells(1, 1).Value
o = 14 + j * 3
Dim WA1 As String
Dim WA2 As String
Dim WA3 As String
Gorev = Worksheets(WS_All).Cells(p, o).Value
SlideNo = Worksheets(WS_All).Cells(p, 34).Value
Egitim_Adi = Worksheets(WS_All).Cells(2, 3).Value
Dim Check1 As Range
Set Check1 = Worksheets(j_WS).Columns("A") 'Egitim_Adi Kontrolü için'
Dim Check2 As Range
Set Check2 = Worksheets(j_WS).Columns("B") 'SlideNo Kontrolü için'
Dim Check3 As Range
Set Check3 = Worksheets(j_WS).Columns("C") 'Gorev Kontrolü için'
答案 0 :(得分:0)
我找到了使用数组的解决方案,并为WS_1,2和3使用了3个案例。