我創建了一個包含動態頁面的多頁面。當用戶窗體啓動時,如果用戶窗體是空的,它將檢查列中特定單元格上的值。然後爲每個非空單元創建一個頁面。如何動態地將單元格值放入excel的多頁文本框中?
這裏是我的代碼片斷
Private Sub UserForm_Initialize()
Dim i As Integer
Dim custDate As Date
Dim vID As String
'ActiveWorkbook.Worksheets("Sheet1").Activate
i = 0
custDate = DateValue(Now)
Range("A1").Offset(1, 0).Select
Do While Not IsEmpty(ActiveCell.Value)
'MsgBox ActiveCell.Address
If custDate = ActiveCell.Value Then 'first column(A) are dates
MultiPage1.Pages.Add
MultiPage1.Pages(0).Controls.Copy 'page 1 is the reference page
i = i + 1 'row counter
ActiveCell.Offset(0, 2).Select 'go to column(C) on the same row where visit ids are located
vID = ActiveCell.Value
MultiPage1.Pages(i).Paste 'copy page 1 contents to new page for each row on the active worksheet
'I guess this is where you put the code to put values
'on a txtbox that was from the reference page which is page 1
ActiveCell.Offset(0, -2).Select 'go back to column(A) to check back dates
End If
ActiveCell.Offset(1, 0).Select 'move to the next row
Loop
MultiPage1.Value = i 'select the new page on the userform
End Sub
現在我的問題是如何把值從細胞到從參考隱藏頁面複製到動態創建新頁面的文本框。我剛剛開始編程VBA昨晚。我是一名Android應用程序開發人員,所以從這一刻開始很難調整。
'MultiPage1.Pages(0).Controls.Copy'是這個文本框要複製? – 2013-02-20 08:59:14
不,這是將被複制的頁面,那麼與參考頁面具有相同內容的新頁面將具有更新單元格值的更新。 – 2013-02-20 09:52:05
該頁面中有多少個文本框? – 2013-02-20 09:53:20