【发布时间】:2017-02-13 04:29:09
【问题描述】:
我需要将用户表单的结果插入到标题中,但我不知道如何将我的代码组合到最终项目中:下面的照片和代码
我需要标题 OK 按钮 1:根据我想要的表格,根据我的标题代码格式化标题,在本例中称为金属
2。在它说“_____”中的金属摘要之后
3。将输入的任何文本插入用户表单文本框中。 (还没有写代码)。
最终结果。 = 对于这张特殊的表格,标题将是“Summary of Metals in Soil, 100 Main Street, USA”
感谢所有帮助!
下面的代码只是临时将结果插入 A1 私人子 Cancel_Click() 我隐藏 结束子
Private Sub OK_Click()
'--- Insert the correct matrix Wording ---
If Check_Soil.Value = -1 Then
Range("A1").Value = "Soil"
ElseIf Check_Sediment.Value = -1 Then
Range("A1").Value = "Sediment"
ElseIf Check_Ground_Water.Value = -1 Then
Range("A1").Value = "Ground Water"
ElseIf Check_Surface_Water.Value = -1 Then
Range("A1").Value = "Surface Water"
End If
Me.Hide
MsgBox "Completed", vbOKOnly
End Sub
Private Sub Check_Soil_Click()
'--- Checks if the Soil Button is Clicked ---
If Check_Soil.Value = True Then
Check_Surface_Water.Value = False
Check_Ground_Water.Value = False
Check_Sediment.Value = False
Else
Check_Soil.Enabled = True
End If
End Sub
Private Sub Check_Surface_Water_Click()
'--- Checks if the Surface Water Button is Clicked ---
If Check_Surface_Water.Value = True Then
Check_Soil.Value = False
Check_Ground_Water.Value = False
Check_Sediment.Value = False
Else
Check_Surface_Water.Enabled = True
End If
End Sub
Private Sub Check_Ground_Water_Click()
'--- Checks if the Ground Water Button is Clicked ---
If Check_Ground_Water.Value = True Then
Check_Surface_Water.Value = False
Check_Soil.Value = False
Check_Sediment.Value = False
Else
Check_Ground_Water.Enabled = True
End If
End Sub
Private Sub Check_Sediment_Click()
'--- Checks if the Sediment Button is Clicked ---
If Check_Sediment.Value = True Then
Check_Surface_Water.Value = False
Check_Soil.Value = False
Check_Ground_Water.Value = False
Else
Check_Sediment.Enabled = True
End If
End Sub
我的其他代码:
SubSelect_Correct_Sheet()
' Select_Correct_Sheet Macro
Sheets("Metals").Select
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = ""
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = "&""Arial,Bold""Summary of Metals in "
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.7)
.RightMargin = Application.InchesToPoints(0.7)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
Application.PrintCommunication = True
End Sub
【问题讨论】:
标签: excel vba formatting userform