我正在尝试使用 Select Case 来记录生产时间表。我尝试了几个角度 - 一个是 Select Case。每次我运行宏时,我都会收到默认错误“输入错误的模型......”
Private Sub Transfer()
Dim ModR As String
Dim Count1 As Integer
Dim Count2 As Integer
Dim Count3 As Integer
Dim Count4 As Integer
Dim Count5 As Integer
Count1 = 0
Count2 = 0
Count3 = 0
Count4 = 0
Count5 = 0
ModR = Worksheets(1).Range("B3").Value
Select Case ModR
Case "Model 1"
Worksheets(1).Range("B4:B6").Copy
Worksheets(2).Range("B3:B5").Offset(Count1, 0).PasteSpecial
Count1 = Count1 + 1
Case "Model 2"
Worksheets(1).Range("B4:B6").Copy
Worksheets(2).Range("B7:B9").Offset(Count2, 0).PasteSpecial
Count2 = Count2 + 1
Case "Mode1 3"
Worksheets(1).Range("B4:B6").Copy
Worksheets(2).Range("B11:B13").Offset(Count3, 0).PasteSpecial
Count3 = Count3 + 1
Case "Model 4"
Worksheets(1).Range("B4:B6").Copy
Worksheets(2).Range("B15:B17").Offset(Count4, 0).PasteSpecial
Count4 = Count4 + 1
Case "Model 5"
Worksheets(1).Range("B4:B6").Copy
Worksheets(2).Range("B19:B21").Offset(Count5, 0).PasteSpecial
Count5 = Count5 + 1
Case Else
MsgBox "Wrong Model Entered / Model Does Not Exist"
End Select
End Sub
Public Sub call_Transfer()
Call Transfer
End Sub
我认为问题出在
ModR = Worksheets(1).Range("B3").Value