|
'第一个问题的解决方法,写一个循环,对每个单元格进行操作,比如说处理范围是: 100*100, 如下:
4 s4 V; ^% A, ~Sub bbb()
4 i; l1 ~+ g8 W8 G6 g2 D/ V Dim i As Long, ii As Long, curStr As String, pos As Long, curValue As Double
3 a) i/ k8 {5 ^0 F1 i Dim Sht As Worksheet
. l/ |; ~6 Z* n; n * Q2 i$ w$ }' U. N
Set Sht = ThisWorkbook.ActiveSheet
6 m( F8 P3 W- O5 h# k4 I4 Z# b For i = 1 To 100; ~3 G' D8 Z$ T, R
For ii = 1 To 100
' ^2 ]' ]% E/ k' C7 V! ^$ W6 Z" j6 b) W curStr = Sht.Cells(i, ii)
0 b( x4 q% c. K8 M If Len(curStr) > 0 Then! k6 t- {. C; y9 O- h3 ?) }
pos = InStr(curStr, "/")2 Z- s* t! E M7 U) h Z2 s5 u9 s
If pos > 0 Then* ~) P5 a7 G7 n- Z; }9 l8 G# Y! t+ {
curValue = CDbl(Left$(curStr, pos - 1)) / Right$(curStr, Len(curStr) - pos)& O& X& b, L. F! @) }3 y
Sht.Cells(i, ii) = curValue1 R: D3 P1 w* } p, E% W
End If
5 x' Y4 v% X$ V4 o# L End If
4 }! c1 m) h! v' x& X/ f* A. U4 j Next ii
: T+ H& q5 D- ?5 L+ C- A) I' i Next i3 N# l( s5 V* Q/ |2 P% }2 f# U4 O6 x
End Sub0 q2 h% q/ C4 [8 @
& ]8 A6 E& z5 i! d& N1 ]" l1 w
不怎么会用excel, 所以代码可能麻烦了,如果哪位高人有更简单的转换方法,欢迎赐教。- {2 M: w/ X8 D! `7 W
- I5 c. D/ ?+ b2 j* m1 \
[ 本帖最后由 kangson 于 13.8.2008 23:13 编辑 ] |
|