5 回答

TA貢獻1847條經驗 獲得超11個贊
1、
Function gs()
gs = ActiveSheet.Cells(ActiveCell.Row, 1) + ActiveSheet.Cells(ActiveCell.Row, 2) + ActiveSheet.Cells(ActiveCell.Row, 3)
End Function
在D列及其右邊列輸入 =gs()
2、
Function gs(a, b, c)
gs = a + b - c '把公式的計算過程寫到這里,輸入公式時只要傳入參數
End Function
在D1輸入 =gs(A1,B1,C1)
復制填充公式
3、
其實要實現 作表中在錄入數據后目標單元格自動計算,但不需要別人看見目標單元格中的公式
可用工作表保護配合單元格鎖定來解決

TA貢獻1856條經驗 獲得超5個贊
1、
Function gs()
gs = ActiveSheet.Cells(ActiveCell.Row, 1) + ActiveSheet.Cells(ActiveCell.Row, 2) + ActiveSheet.Cells(ActiveCell.Row, 3)
End Function
在D列及其右邊列輸入 =gs()
2、
Function gs(a, b, c)
gs = a + b - c '把公式的計算過程寫到這里,輸入公式時只要傳入參數
End Function
在D1輸入 =gs(A1,B1,C1)
復制填充公式
3、
其實要實現 作表中在錄入數據后目標單元格自動計算,但不需要別人看見目標單元格中的公式
可用工作表保護配合單元格鎖定來解決

TA貢獻1807條經驗 獲得超9個贊
Sub test()
Dim i, j As Integer
Dim a, b As String
For i = 1 To ActiveSheet.UsedRange.Rows.Count
If Range("A" & i) = 1 Then
b = Range("B" & i).Value
For j = 1 To ActiveSheet.UsedRange.Rows.Count
If Int(j / 1000) * 1000 = j Then Application.StatusBar = "A 列進度:" & i & " " & "C列進度:" & j
a = Range("C" & j).Value
If InStr(1, a, b) <> 0 Then
Range("C" & j).Value = ""
End If
DoEvents
End If
End Sub'狀態欄寫的有進度

TA貢獻1780條經驗 獲得超1個贊
全數組,速度稍快些:
Sub test()
Dim arr, brr, i&, j&, m&, n&
m = Cells(Rows.Count, "b").End(xlUp).Row
n = Cells(Rows.Count, "c").End(xlUp).Row
arr = Range("A1:B" & m)
brr = Range("C1:C" & n)
For i = 1 To n
For j = 1 To m
If arr(j, 1) = 1 Then
If InStr(brr(i, 1), arr(j, 2)) > 0 Then
brr(i, 1) = ""
Exit For
End If
End If
Next
Next
Cells(1, "c").Resize(n, 1) = brr
MsgBox "OK!"
End Sub
添加回答
舉報