请教:为什么会出现类型不匹配?

cocly cocly 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
在VBA中如下代码:
Dim RowCounter As Long
RowCounter = Worksheets(1).UsedRange.Rows.Count()

Dim RowCycle As Long
Dim ActiveCell As Range
Dim AgeRange As Range
Dim SexRange As Range
Dim Age As Integer
Dim YearCount As Integer

For RowCycle = 1 To RowCounter

Set ActiveCell = Worksheets(1).Range("AI" & (RowCycle + 1))
Set AgeRange = Worksheets(1).Range("E" & (RowCycle + 1))
Set SexRange = Worksheets(1).Range("D" & (RowCycle + 1))

Age = CInt(Format(AgeRange, "yyyymmdd") / 10000) //这条语句出现类型不匹配
If (SexRange.Text = "男" & Age <= 1947) Then YearCount = Age - 1932
If (SexRange.Text = "女" & Age <= 1952) Then YearCount = Age - 1932
If (YearCount >= 0) Then ActiveCell.Value = CLng(YearCount * 1300) + CLng(15000) Else ActiveCell.Value = 15000

Next RowCycle

如上面代码,在调试中可以执行,但是在上面Age那一行出现“类型不匹配”的提示,请问是为什么呢?应该怎么修改?
谢谢大家~!
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
cocly
VBA 2,506 成员 10,830 内容