|
用VBA判断三个条件只要满足其中一个则结束过程
爱疯 发表于 2016-2-5 09:11
Private Sub CommandButton1_Click()
With ActiveSheet.ChartObjects("图表 1").Chart.SeriesCollecti ...
请老师赐教,例如录入窗体TextBox22对应“资料库表”A列为(姓名),TextBox23:TextBox25对应B:D列为(项目1、项目2、项目3),三个条件只要满足其中的一个就结束过程。
例如:窗体TextBox22(姓名)=张三,TextBox23、TextBox24=“”、TextBox25=百姓超市,“资料库表”A3=张三,B3=百姓超市、C3=华隆超市、D3=苏果超市,满足1个或2个及3个条件都结束过程.
下面是3个条件都满足才结束过程,请老师修改谢谢!- <div>Private Sub CommandButton1_Click()
- Dim a As Integer
- Dim i As Long
- Dim myControl As Control
- Set d = CreateObject("Scripting.Dictionary")
- ' ARR = Sheets("资料库").Range("a3:d" & Sheets("资料库").[d999].End(3).Row)
- Myr = Sheet6.[a65536].End(xlUp).Row
- ARR = Sheet6.Range("a3:d" & Myr)
- For i = 1 To UBound(ARR)
- d(ARR(i, 1) & ARR(i, 2) & ARR(i, 3) & ARR(i, 4)) = i
- Next
- If d.exists(TextBox22.Value & TextBox23.Value & TextBox24.Value & TextBox25.Value) Then
- CreateObject("WScript.Shell").Popup "该客户已存在!", 1, "提示"
- Unload Me
- Exit Sub
- End If
- a = Sheet6.[a65536].End(xlUp).Row
- With Sheet6.Range("A" & a + 1)
- .Offset(0, 0).Value = TextBox22.Value
- .Offset(0, 1).Value = TextBox23.Value
- .Offset(0, 2).Value = TextBox24.Value
- .Offset(0, 3).Value = TextBox25.Value
- .Offset(0, 4).Value = TextBox26.Value
- .Offset(0, 5).Value = TextBox27.Value
- .Offset(0, 6).Value = TextBox28.Value
- End With
- End Sub
复制代码 |
|