宏调用

时间:2018-09-13 13:49:45

标签: excel vba excel-vba listbox userform

我有一个简单的代码,当用户在某些单元格中输入大于2.5的值时,应调用Userform(CorrectiveActions)。

Private Sub Worksheet_Change(ByVal target As Range)
If target.Count > 1 Then Exit Sub
If Not Application.Intersect(target, Me.Range("F11:F1292,K11:K1292,P11:P1292")) Is Nothing Then
    If target >= 2.5 And IsNumeric(target) And Intersect(target, Me.Range("K11:K1292")) Is Nothing Or target.Offset(0, 1) >= 2.5 And Intersect(target, Me.Range("F11:F1292,P11:P1292")) Is Nothing Then CorrectiveActions.Show
End If
End Sub

该用户窗体包含一个列表框,我想填充大于2.5的那个框下方的单元格。我使用了以下代码:

Private Sub ListBox1_Click()

Dim cellRow As Integer
Dim cellCol As Integer

cellRow = ActiveCell.Row
cellCol = ActiveCell.Column
Cells(cellRow, cellCol).Offset(1, 0).Value = ListBox1

End Sub

当我手动启动该用户窗体时,它运行良好。但是,当我在指定的单元格中输入一个大于2.5的值时,将显示“用户窗体”,但将不起作用。也就是说,该单元格不会被填充。

0 个答案:

没有答案
相关问题