返回列表 上一主題 發帖

[發問] 跳格累加

本帖最後由 singo1232001 於 2023-12-11 11:00 編輯

Private Sub Worksheet_Change(ByVal Target As Range)
'防錯很好用
If Target.Height > 10000000 Then Exit Sub  '防全選溢位報錯
If Target.Width > 1000000 Then Exit Sub   '防全選溢位報錯
If Target.Count > 1 Then Exit Sub      '防多選回溯報錯
If Target.Value = "" Then Exit Sub    '防空值計算報錯
If Target.Column > 1 Then Exit Sub
If Target.Row > 1 Then Exit Sub
If IsNumeric(Target.Value) = False Then Exit Sub  '防非數字計算報錯

'二元一次聯立方程式 (可刪除註解)
'y = ax + b
'0= 1a + b     '1列=0
'10= 6a + b    '6列=10
'a = -b
'代入 10=-5b
'b=-2
'代回 0=a-2
'a=2
'求出 y=2x-2

ReDim ar(1 To 101, 0)
For i = 1 To 101 Step 5
ar(i, 0) = i * 2 - 2 + Target.Value   '代入公式y=2x-2 +原始值
Next
Target.Resize(101, 1) = ar
End Sub

TOP

        靜思自在 : 願要大、志要堅、氣要柔、心要細。
返回列表 上一主題