2
我有一個用戶窗體,它使用文本輸入和一個選項按鈕選擇,將數據輸入到具有特定分類的工作表上。將用戶窗體數據輸入到下一個空單元格區域
使用來自計數器i的值將條目放置在工作表中的特定單元格中,並可通過使用按鈕將其移至位於同一工作簿中的「歸檔」工作表。這可以在列表中留下一個免費的條目。即
Job 1 is entered
Job 2 is entered
Job 3 is entered
Job 2 is archived
There now exists a space between job 1 and 3.
我所要做的,就是創建一個循環,這將檢查一個空單元格範圍,然後將用戶窗體數據,下一個可用空單元格。該數據被輸入每5個細胞,使A5,A10,A15 ......等
我目前擁有的代碼如下:
If UserForm1.OptionButton1.Value = True Then
If Range("A" & (5 * i)).Value = "" Then
ActiveSheet.Range("A" & (5 * i) & ":" & "O" & (3 + (5 * i))).Select
With Selection.Interior
.Color = RGB(239, 231, 121)
End With
With Worksheets("Active Jobs")
.Range("A" & (5 * i)) = UserForm1.TextBox1 'Place job 5 cells apart
.Range("B" & (5 * i) & ":" & "E" & (3 + (5 * i))).Merge
.Range("B" & (5 * i)) = UserForm1.TextBox2
.Range("B" & (5 * i) & ":" & "E" & (3 + (5 * i))).VerticalAlignment = xlTop
.Range("G" & (5 * i) & ":" & "O" & (3 + (5 * i))).Merge
Set t = .Range("T" & (5 * i))
Set btn = .Buttons.Add(t.Left, t.Top, t.Width, t.Height)
With btn
.Name = "RemovetoArchive" & i1
.Caption = "Archive"
.OnAction = "RemovetoArchive"
End With
End With
i = i + 1
ElseIf Range("A" & (5 * i)).Value <> "" Then
For i = 1 To 25
'I can't figure out how to implement the for loop here.
Next i
End If
也許利用'End(xlDown)'會有所幫助。用Range(「A」&(5 * i))。End(xlDown).Offset(1)'替換循環以獲得空白單元格以輸入數據。 –