以下是大大的程式,變數a,b為小數(例:4.5、3.8),執行結果出現溢位問題,請各位大大幫我看看
sub ex()
Dim a As Single, b As Single, c As Single, d As Double
dim kkk as String
ccc = Chr(67)
ddd = Chr(68)
ggg = Chr(71)
For i = 3 To k
xxx = i
a = Range(ccc + xxx).Value
b = Range(ddd + xxx).Value
c = a + (a - b)
d = c / a
Range(ggg + xxx).Value = Format(d, "00.00")
Next
End sub作者: c_c_lai 時間: 2012-4-18 12:51
回復 1#caichen3
For i = 3 To k
請問 k 為多少?作者: chin15 時間: 2012-4-18 14:01
在創新商機指數G欄中有若干的數值,我想從中選出2個最大的數值並有紅色網底。
選出來的數值放置於range(M1:M2), range("I1")=2是我將選出的個數。
如果 G欄中的數值等於range(M1:M2)就給予紅色網底
以下是相關程式碼:
sub ex()
Dim myrange As Range
Dim U As Range
Dim zzz as string,sss as string
Dim w As Single
Dim q As Single
mmm = Chr(77)
Set myrange = Range("G3:G11" ) '設定範圍
w = Application.WorksheetFunction.Max(myrange) '取最大數值
Range("M1").Value = w
For Z = 2 To 2 '取第二大數值
zzz = Z
q = Application.WorksheetFunction.Large(myrange, Z)
Range(mmm & zzz).Value = Format(q, "00.00")
Next
With ActiveSheet
For Each U In .Range("G3:G200")
For s = 1 To 2
sss = s
If U = Range(mmm & sss).Value Then
U.Interior.ColorIndex = 3
Else
U.Interior.ColorIndex = xlNone
End If
Next
Next
End With
End sub
執行結果卻只有g欄中1.42的數值底色為紅色,1.5卻沒有,一直找不出原因!!作者: Hsieh 時間: 2012-4-19 15:45
請教h大大
k = (A + (A - A.Offset(, 1))) / A
A.Offset(, 4) = k
ReDim Preserve Ar(s)
Ar(s) = k
s = s + 1
Next
這段程式碼是在做什麼呢??
k = (A + (A - A.Offset(, 1))) / A k值的作用是什麼作者: Hsieh 時間: 2012-4-19 18:01