-
回首忆惘然
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、其实要实现 作表中在录入数据后目标单元格自动计算,但不需要别人看见目标单元格中的公式可用工作表保护配合单元格锁定来解决
-
RISEBY
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、其实要实现 作表中在录入数据后目标单元格自动计算,但不需要别人看见目标单元格中的公式可用工作表保护配合单元格锁定来解决
-
浮云间
‘直接赋值就可以Sub run()For i = 1 To 100Sheets("Sheet1").Cells(i, 4) = "=A" & i & "+B" & i & "-C" & iNextEnd Sub
-
函数式编程
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 Next End If NextEnd Sub'状态栏写的有进度
-
慕神8447489
全数组,速度稍快些:Sub test()Dim arr, brr, i&, j&, m&, n&m = Cells(Rows.Count, "b").End(xlUp).Rown = Cells(Rows.Count, "c").End(xlUp).Rowarr = Range("A1:B" & m)brr = Range("C1:C" & n)For i = 1 To nFor j = 1 To mIf arr(j, 1) = 1 ThenIf InStr(brr(i, 1), arr(j, 2)) > 0 Thenbrr(i, 1) = ""Exit ForEnd IfEnd IfNextNextCells(1, "c").Resize(n, 1) = brrMsgBox "OK!"End Sub