我在excel和工作表中创建了一个数据库,需要使用数据库中某个记录的信息进行复制和填充。我需要打开一个新的工作簿文件,文件名上要有个人的名字,并且工作簿中要填充复制的工作表以及转移过来的一条记录中的信息。
在VBA中使用excel我真的很陌生,需要帮助。
Private Sub Create_Plan_Click()
Dim UserFilename As String
Dim FullName As String
UserFilename = Combo_Title & Txt_FirstName & Txt_MiddleInit & Txt_LastName & Combo_Suffix
FullName = Combo_Title & " " & Txt_FirstName & " " & Txt_MiddleInit & ". " & Txt_LastName & " " & Combo_Suffix
Unload Choose_User
Meal_Cat_Form.Show
End Sub
我不想显示Meal_Cat_Form,而是将记录与数据库文件中的其他工作表一起复制,并使用复制的工作表和所选记录中的信息创建一个全新的工作簿。
答案 0 :(得分:0)
这是一个提示,旨在帮助您解决问题
第1步-可以在何处找到数据的加载项信息
Private Sub Create_Plan_Click()
Dim UserFilename As String
Dim FullName As String
Dim dbSrcRow as long, dbSrcSht as Worksheet ' These 2 Added
UserFilename = Combo_Title & Txt_FirstName & Txt_MiddleInit & Txt_LastName & Combo_Suffix
FullName = Combo_Title & " " & Txt_FirstName & " " & Txt_MiddleInit & ". " & Txt_LastName & " " & Combo_Suffix
' You also need to provide info as to where the data base record is
Set dbSrcSht = "dbSheet" ' You need to edit this
Set dbSrcRow = 123 ' and this too
' Done
' I've swapped these next 2 lines around
' seems you need to carryout the copying before you loose/unload the data
Meal_Cat_Form.Show ' This will become the copy routine not a form
Unload Choose_User
' Done
End Sub
第2步-有关需要复制哪些工作表的加载项信息
' You also need to provide info as to which sheets need to be copied
Set Shts2Copy = "Sht1,Sht2,Sht3" ' You need to edit this
' Done
最后-您需要创建一个新的工作簿并填写信息,然后将其保存