0

我有一个看起来像这样的 Excel 文件:

Col A   Col B   Col C
------  -----   -------
ABC     3600    Title 1
DEF     3601    Title 2
ABC     3603    Title 3
GHI     3603    Title 4
ABC     3602    Title 5
JKL     3604    Title 6

等等

我需要这样说:如果 A 列是“ABC”而 B 列不是(3601,3602,3603,3700),那么在 D 列(空列)中放置一个“1”。

我究竟如何把它放在VBA中?

4

1 回答 1

3

你需要VBA吗?

一个公式是:

=IF(A1="ABC";IF(OR(B1=3601;B1=3602;B1=3603;B1=3700);"";1);"")

下图中有一个错误(单元格移动),上面的公式是正确的。

在此处输入图像描述

VBA:

Function CellCombination(Cell1 As Range, Cell2 As Range) As String
  CellCombination = ""
    If Cell1.Value = "ABC" Then
      Select Case Cell2.Value
        Case 3601 To 3603, 3700
        Case Else
          CellCombination = "1"
      End Select
   End If
End Function

带有示例的电子表格:http ://www.bumpclub.ee/~jyri_r/Excel/CellCombinations.xls

于 2013-01-23T21:33:39.650 回答