VBA Excel如何在一个事件中对两个sheet进行同样的插入操作?
现在ActRow2=这一句显示typemismatchPrivateSubcbt_Submit_Click()DimColm_CountAsIntegerDimActRo...
现在 ActRow2 = 这一句显示type mismatch
Private Sub cbt_Submit_Click()
Dim Colm_Count As Integer
Dim ActRow As Long
Dim ActRow2 As Long
ActRow = Sheets(NewSheetName).Cells(Rows.Count, 1).End(xlUp).Row
Sheets(NewSheetName).Rows(ActRow + 1).RowHeight = 20
With Sheets(NewSheetName)
With .Cells(Rows.Count, 1).End(xlUp)
'.Pattern = xlSolid
.Offset(1, 0) = textbox_ProjectName
.Offset(1, 1) = textbox_WBS
.Offset(1, 2) = cbo_CustomerArea
.Offset(1, 3) = textbox_MachineType
.Offset(1, 4).NumberFormat = "mm/dd/yyyy"
.Offset(1, 4) = dptPJInfo
.Offset(1, 5) = cbo_ProjectLevel
.Offset(1, 6) = cbo_PJM
.Offset(1, 7) = cbo_ECS
.Offset(1, 8) = textbox_PJEEND
End With
End With
'ErrorHandle:
' MsgBox Err.Number & " : " & Err.Description
' Exit Sub
ActRow2 = Sheets(Sheet2).Cells(Rows.Count, 1).End(xlUp).RowWith Sheets(Sheet2)
With .Cells(Rows.Count, 1).End(xlUp)
'.Pattern = xlSolid
.Offset(1, 0) = textbox_ProjectName
.Offset(1, 1) = textbox_WBS
.Offset(1, 2) = cbo_CustomerArea
.Offset(1, 3) = textbox_MachineType
.Offset(1, 4).NumberFormat = "mm/dd/yyyy"
.Offset(1, 4) = dptPJInfo
.Offset(1, 5) = cbo_ProjectLevel
.Offset(1, 6) = cbo_PJM
.Offset(1, 7) = cbo_ECS
.Offset(1, 8) = textbox_PJEEND
End With
End With
'ErrorHandle:
' MsgBox Err.Number & " : " & Err.Description
' Exit Sub
End Sub 展开
Private Sub cbt_Submit_Click()
Dim Colm_Count As Integer
Dim ActRow As Long
Dim ActRow2 As Long
ActRow = Sheets(NewSheetName).Cells(Rows.Count, 1).End(xlUp).Row
Sheets(NewSheetName).Rows(ActRow + 1).RowHeight = 20
With Sheets(NewSheetName)
With .Cells(Rows.Count, 1).End(xlUp)
'.Pattern = xlSolid
.Offset(1, 0) = textbox_ProjectName
.Offset(1, 1) = textbox_WBS
.Offset(1, 2) = cbo_CustomerArea
.Offset(1, 3) = textbox_MachineType
.Offset(1, 4).NumberFormat = "mm/dd/yyyy"
.Offset(1, 4) = dptPJInfo
.Offset(1, 5) = cbo_ProjectLevel
.Offset(1, 6) = cbo_PJM
.Offset(1, 7) = cbo_ECS
.Offset(1, 8) = textbox_PJEEND
End With
End With
'ErrorHandle:
' MsgBox Err.Number & " : " & Err.Description
' Exit Sub
ActRow2 = Sheets(Sheet2).Cells(Rows.Count, 1).End(xlUp).RowWith Sheets(Sheet2)
With .Cells(Rows.Count, 1).End(xlUp)
'.Pattern = xlSolid
.Offset(1, 0) = textbox_ProjectName
.Offset(1, 1) = textbox_WBS
.Offset(1, 2) = cbo_CustomerArea
.Offset(1, 3) = textbox_MachineType
.Offset(1, 4).NumberFormat = "mm/dd/yyyy"
.Offset(1, 4) = dptPJInfo
.Offset(1, 5) = cbo_ProjectLevel
.Offset(1, 6) = cbo_PJM
.Offset(1, 7) = cbo_ECS
.Offset(1, 8) = textbox_PJEEND
End With
End With
'ErrorHandle:
' MsgBox Err.Number & " : " & Err.Description
' Exit Sub
End Sub 展开
2个回答
展开全部
应该这样写
ActRow2 = Sheets(“Sheet2”).Cells(Rows.Count, 1).End(xlUp).Row
With Sheets(“Sheet2”)
引号不能少
ActRow2 = Sheets(“Sheet2”).Cells(Rows.Count, 1).End(xlUp).Row
With Sheets(“Sheet2”)
引号不能少
追问
确实没有报错了,但是内容没有写道Sheet2里面阿?
追答
应该没错的了,你再检查检查。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询