|
'第一个问题的解决方法,写一个循环,对每个单元格进行操作,比如说处理范围是: 100*100, 如下:9 [' H2 f, I( a; _
Sub bbb()0 z$ p S' Z2 q5 }' j, |
Dim i As Long, ii As Long, curStr As String, pos As Long, curValue As Double
3 M+ S+ y5 w6 I* A7 m$ v; |* r Dim Sht As Worksheet) B' o- x0 n# u; f) x
' n: u( V' t& k. m
Set Sht = ThisWorkbook.ActiveSheet
( C- j: p6 `- H For i = 1 To 100
- z: m% }1 D& H For ii = 1 To 100) b. o- a& q0 q) B
curStr = Sht.Cells(i, ii)
; \9 `1 r' H) y* w1 M) u If Len(curStr) > 0 Then2 k3 O! R) |; Q) F/ Z# s
pos = InStr(curStr, "/")& r9 a2 P# @/ C2 z( U
If pos > 0 Then3 R( R3 c( K7 p% c! N* m
curValue = CDbl(Left$(curStr, pos - 1)) / Right$(curStr, Len(curStr) - pos); o, O' N: ?! K5 @; L8 t. @
Sht.Cells(i, ii) = curValue
6 E( Z9 i; X/ c3 ~9 M( w( D7 f End If
9 Y/ W6 d }6 m& v End If3 g6 e# s' q5 g7 g
Next ii7 B* l. a. r* c6 X
Next i& T2 }, X4 q1 d1 r9 B. F
End Sub
; q3 |4 Q! c8 y# I. c
5 z. R' `. U, Z; V, C6 V不怎么会用excel, 所以代码可能麻烦了,如果哪位高人有更简单的转换方法,欢迎赐教。
8 K+ o2 H7 A+ L6 b( g: W- u; T9 S+ d% E5 ^ X# `/ ~
[ 本帖最后由 kangson 于 13.8.2008 23:13 编辑 ] |
|