我尝试在代码执行时更新标签。现在,这可以在另外两个用户表单中使用完全相同的代码(更新),但在这一个中他并不想更新信息。
奇怪的是,当我逐行执行代码时,它会更新它。所以标签的名称等没有错。
这是我的代码:
Dim MSWorkbook As Workbook, MSSheet As Worksheet, GMSheet As Worksheet, i As Integer, LastRow As Integer, LastRowGM As Integer
Dim aantal As Integer, ColNum As Integer
'variabelen toewijzen
Set GMSheet = ThisWorkbook.ActiveSheet
Set MSWorkbook = Workbooks.Open("....")
Set MSSheet = MSWorkbook.ActiveSheet
GMSheet.Activate
ColNum = 72 'letter H
'progress bar opmaken
ParetoPerCategorie.PGB.Max = 11
ParetoPerCategorie.PGB.Min = 0
ParetoPerCategorie.PGB.Value = 1
ParetoPerCategorie.lblInfo.Caption = "Voorbereidend werk"
LastRow = MSSheet.Range("G5").End(xlDown).Row
LastRowGM = GMSheet.Range("A3").End(xlDown).Row
'Data ophalen (per categorie alle 40 getallen optellen en plaatsen in de juiste cel.
For j = 3 To LastRowGM
aantal = 0
ParetoPerCategorie.lblInfo.Caption = "Bezig met categorie " & GMSheet.Range("A" & j).Value
ParetoPerCategorie.lblAantal.Caption = "categorie " & j - 2 & " van de " & LastRowGM - 2
ParetoPerCategorie.PGB.Value = j - 1
Application.Wait (Now + TimeValue("00:00:01"))
For i = LastRow - 40 To LastRow
aantal = aantal + MSSheet.Cells(i, Chr(ColNum)).Value
Next i
GMSheet.Range("B" & j).Value = aantal
ColNum = ColNum + 1
Next j
MSWorkbook.Close False
Unload Me
我不知道为什么在我运行它时它没有做到。提前谢谢!