【发布时间】:2017-02-27 02:17:37
【问题描述】:
我的用户表单中有两个“组合框”和一个“txtbox”,在工作簿“sheet1”中,我在 A 列有名称,B 列有月份,C 到 N 列是一月到十二月,其中包含生产时间每个名称/特定月份
-cboName
-cboMonth
-txtHours
我使用下面的代码来填充 txtHours
Private Sub cboName_Change()
Dim EName As String
Dim Row, Col As Integer
EName = Me.cboName.Text
If EName <> "" Then
With Application.WorksheetFunction
Row = .Match(EName, Sheets("sheet1").Range("A2:A100"), 0)
GetMonthNum (Me.cboMonth.Text)
txtShiftHours.Value = Sheets("sheet1").Cells(Row + 1, Col + 3)
End With
End If
End Sub
Private Sub GetMonthNum(Month As String)
Select Case Month
Case Jan
Col = 3
Case Feb
Col = 4
Case Mar
Col = 5
Case Apr
Col = 6
Case May
Col = 7
Case June
Col = 8
Case July
Col = 9
Case Aug
Col = 10
Case Sept
Col = 11
Case Oct
Col = 12
Case Nov
Col = 13
Case Dec
Col = 14
End Select
End Sub
但无论 cboMonth 上的月份选择如何,txtProduct 都会填充第 3 列,因为这一行
txtShiftHours.Value = Sheets("sheet1").Cells(Row + 1, Col + 3)
请帮帮我 谢谢
【问题讨论】: