首页 > 生活 > > 正文
2024-04-05 23:00:56

formular1c1属性(formular1c1)

导读 大家好,我是小夏,我来为大家解答以上问题。formular1c1属性,formular1c1很多人还不知道,现在让我们一起来看看吧!1、先试一试这个公式...

大家好,我是小夏,我来为大家解答以上问题。formular1c1属性,formular1c1很多人还不知道,现在让我们一起来看看吧!

1、先试一试这个公式: =COUNT(MATCH(ARRAY1,ARRAY2,0))

2、 如果不行的话看一下条件格式

3、 如果不行再用VB:

4、 Function CountColor(rng As Range, lColor As Long) As Long

5、

6、Dim cel As Range

7、

8、CountColor = 0

9、

10、For Each cel In rng

11、

12、 If GetFontColor(cel) = lColor Then

13、

14、

15、 CountColor = CountColor + 1

16、

17、 End If

18、

19、Next

20、 End Function

21、 Sub checkFormatCondition()

22、

23、Dim cel As Range

24、

25、Dim lCount As Long

26、

27、lCount = 0

28、

29、ThisWorkbook.Activate

30、

31、Worksheets(1).Select

32、

33、For Each cel In ThisWorkbook.Worksheets(1).Range("B3:B50")

34、

35、 If GetFontColor(cel) = vbRed Then

36、

37、

38、 lCount = lCount + 1

39、

40、 End If

41、

42、Next

43、

44、MsgBox lCount

45、 End Sub

46、 Function GetFontColor(rng As Range) As Long

47、

48、Dim cel As Range

49、

50、Dim tmp As Variant

51、

52、Dim i As Integer

53、

54、Dim fmlNorm As String, fmlR1C1 As String, fmlA1 As String

55、

56、Dim bMatch As Boolean

57、

58、

59、 Set cel = rng.Cells(1, 1)

60、

61、GetFontColor = cel.Font.Color

62、

63、

64、 If cel.FormatConditions.Count > 0 Then

65、

66、 With cel.FormatConditions

67、

68、

69、 For i = 1 To .Count

70、

71、

72、

73、 fmlNorm = .Item(i).Formula1

74、

75、

76、

77、 If Left(fmlNorm, 1) = "=" Then

78、

79、

80、

81、

82、 fmlR1C1 = Application.ConvertFormula(fmlNorm, xlA1, xlR1C1, , ActiveCell)

83、

84、

85、

86、

87、 fmlA1 = Application.ConvertFormula(fmlR1C1, xlR1C1, xlA1, xlAbsolute, cel)

88、

89、

90、

91、

92、 bMatch = Application.Evaluate(fmlA1)

93、

94、

95、

96、 Else

97、

98、

99、

100、

101、 Select Case .Item(i).Operator

102、

103、

104、

105、

106、

107、Case xlEqual

108、

109、

110、

111、

112、

113、 fmlNorm = cel & "=" & .Item(i).Formula1

114、

115、

116、

117、

118、

119、Case xlNotEqual

120、

121、

122、

123、

124、

125、 fmlNorm = cel & "<>" & .Item(i).Formula1

126、

127、

128、

129、

130、

131、Case xlBetween

132、

133、

134、

135、

136、

137、 fmlNorm = "AND(" & .Item(i).Formula1 & "<=" & cel & "," & cel & "<=" & .Item(i).Formula2 & ")"

138、

139、

140、

141、

142、

143、Case xlNotBetween

144、

145、

146、

147、

148、

149、 fmlNorm = "OR(" & .Item(i).Formula1 & ">" & cel & "," & cel & ">" & .Item(i).Formula2 & ")"

150、

151、

152、

153、

154、

155、Case xlLess

156、

157、

158、

159、

160、

161、 fmlNorm = cel & "<" & .Item(i).Formula1

162、

163、

164、

165、

166、

167、Case xlLessEqual

168、

169、

170、

171、

172、

173、 fmlNorm = cel & "<=" & .Item(i).Formula1

174、

175、

176、

177、

178、

179、Case xlGreater

180、

181、

182、

183、

184、

185、 fmlNorm = cel & ">" & .Item(i).Formula1

186、

187、

188、

189、

190、

191、Case xlGreaterEqual

192、

193、

194、

195、

196、

197、 fmlNorm = cel & ">=" & .Item(i).Formula1

198、

199、

200、

201、

202、 End Select

203、

204、

205、

206、

207、 bMatch = Application.Evaluate(fmlNorm)

208、

209、

210、

211、 End If

212、

213、

214、

215、 If bMatch Then

216、

217、

218、

219、

220、 On Error Resume Next

221、

222、

223、

224、

225、 tmp = .Item(i).Font.Color

226、

227、

228、

229、

230、 If Err.Number = 0 Then GetFontColor = tmp

231、

232、

233、

234、

235、 Err.Clear

236、

237、

238、

239、

240、 On Error GoTo 0

241、

242、

243、

244、

245、 Exit For

246、

247、

248、

249、 End If

250、

251、

252、 Next i

253、

254、 End With

255、

256、End If

257、 End Function

258、

259、记着多给分哦

本文到此讲解完毕了,希望对大家有帮助。