Home > Back-end >  Need sum some values left from activeCell. Where error?
Need sum some values left from activeCell. Where error?

Time:01-30

Yeah i ve done it! But i need one thing -if activecell in column b - paste =Page1!E2

Sub FOT()
Dim rgb
ActiveCell.Offset(0, -1).Select
With ActiveCell
    Set Rng = .EntireRow.Cells(2).Resize(1, .Column - 1)
   .Offset(0, 1).Select
   rgb = Evaluate("=SUM(" & Rng.Address & ")")
End With
If rgb < 1500001 Then
ActiveCell.Formula = "=Page1!E2"
Else
ActiveCell.Formula = "=Page1!F2"
End If
ActiveCell.Value = ActiveCell.Value
End Sub

CodePudding user response:

Sub FOT()
Dim rgb
If ActiveCell.Column() = 2 Then
ActiveCell.Formula = "=Page1!E2"
Exit Sub
End If

ActiveCell.Offset(0, -1).Select
With ActiveCell
    Set Rng = .EntireRow.Cells(2).Resize(1, .Column - 1)
   .Offset(0, 1).Select
   rgb = Evaluate("=SUM(" & Rng.Address & ")")
End With
If rgb < 1500001 Then
ActiveCell.Formula = "=Page1!E2"
Else
ActiveCell.Formula = "=Page1!F2"
End If
ActiveCell.Value = ActiveCell.Value
End Sub
  •  Tags:  
  • Related