|
Sub 引入公式()
y = Range("a65536").End(xlUp).Row 'A列最后可见单元的行号
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Range("d3:d" & y).Select
Selection.FormulaR1C1 = _
"=IF(RC[2]<>"""",IF(MOD(RIGHT(LEFT(RC[2],17)),2),""男"",""女""),)"
Range("E3:e" & y).Select
Selection.FormulaR1C1 = _
"=IF(RC6<>"""",DATEDIF(TEXT((LEN(RC6)=15)*19&MID(RC6,7,6+(LEN(RC6)=18)*2),""#-00-00""),TODAY(),""y""),)"
Range("g3:g" & y).Select
Selection.FormulaR1C1 = _
"=IF(RC2<>"""",""**县""&VLOOKUP(--MID(RC2,1,6),代码!C[-5]:C[-4],2,),)"
Range("a3:n" & y).Select '选择所有公式区域
'复制并选择性粘贴数值
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("a" & y + 1).Select
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
End Sub
这个代码还能精简和优化吗?
[ 本帖最后由 lbl016 于 2010-4-17 10:06 编辑 ] |
|