Private TargetSheet As Worksheet Private y As Integer Private x As Integer Private Const RowMax As Integer = 10 Private Const ColMax As Integer = 20 Sub StartProgram() Set TargetSheet = GetSheet("Sheet1") If TargetSheet Is Nothing Then Exit Sub Call SetTestCellData(TargetSheet) y = 1 x = 1 UserForm1.Show vbModeless Call Output End Sub Public Function GetSheet(ByVal SheetName As String _ , Optional ByVal MsgFlag As Boolean = True) As Worksheet Dim wAns As Worksheet On Error GoTo ErrMsg Set wAns = ThisWorkbook.Sheets(SheetName) Set GetSheet = wAns Exit Function ErrMsg: Set GetSheet = Nothing If MsgFlag Then MsgBox SheetName & " シート(or グラフシート)が存在しません。" End If End Function Private Sub SetTestCellData(st As Worksheet) Dim row As Integer Dim col As Integer Dim Data(1 To RowMax, 1 To ColMax) As Variant For row = 1 To UBound(Data, 1) For col = 1 To UBound(Data, 2) Data(row, col) = CStr(row) & "," & CStr(col) Next Next st.Range("$A$1").Resize(UBound(Data, 1), UBound(Data, 2)).Value = Data End Sub Private Sub Output() UserForm1.TextBox6.Text = TargetSheet.Cells(y, x).Value y = y + 1 If y > RowMax Then y = 1 x = x + 1 If x > ColMax Then Exit Sub End If Application.OnTime Now + TimeValue("00:00:01"), "ThisWorkbook.Output" End Sub