请教:为什么会出现类型不匹配?
cocly 2008-08-03 09:33:14 在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那一行出现“类型不匹配”的提示,请问是为什么呢?应该怎么修改?
谢谢大家~!