Hi to all
I have two almost the same codes but for different ranges. Separately they working perfect, but If I combine them, only one working, in range ("F25:F50") and NOT for range ("E12:E24").
How to combine them correctly ?
Joe4 it's your code, maybe you can help me again ?
Thanks
And second one:
I have two almost the same codes but for different ranges. Separately they working perfect, but If I combine them, only one working, in range ("F25:F50") and NOT for range ("E12:E24").
How to combine them correctly ?
Joe4 it's your code, maybe you can help me again ?
Thanks
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Source: https://www.mrexcel.com/board/threads/copy-cell-value-via-vba-if-specific-cell-is-changed.1233988/post-6047652
Dim rng As Range
Dim cell As Range
' See if any cells updated in column C
Set rng = Intersect(Target, Range("F25:F50"))
If rng Is Nothing Then Exit Sub
' Loop though all updated rows in column C
For Each cell In rng
If IsNumeric(cell.Value) And cell.Value > 0 Then
Application.EnableEvents = False
If cell.Offset(0, 2) > 0 Then
cell.Offset(0, -1) = Range("G3") * cell * (1 + Range("$I$3"))
Else
cell.Offset(0, -1) = Range("G3") * cell
End If
Range("E11") = Range("F11") * Range("G3")
Range("G11") = Range("E11") / Range("H3")
cell.Offset(0, 1) = Range("G3") * cell / Range("H3")
cell.Offset(0, -2) = Range("H3")
cell.Offset(0, -3) = Range("G3")
cell.Offset(0, -4) = Date
Else
Application.EnableEvents = False
cell.Offset(0, 0) = "0"
cell.Offset(0, 1) = "0"
cell.Offset(0, 2) = ""
cell.Offset(0, -1) = "0"
cell.Offset(0, -2) = ""
cell.Offset(0, -3) = ""
cell.Offset(0, -4) = ""
End If
Next cell
Application.EnableEvents = True 'reenable events
End Sub
And second one:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Source: https://www.mrexcel.com/board/threads/copy-cell-value-via-vba-if-specific-cell-is-changed.1233988/post-6047652
Dim rng2 As Range
Dim cell As Range
Set rng2 = Intersect(Target, Range("E12:E24"))
If rng2 Is Nothing Then Exit Sub
For Each cell In rng2
If IsNumeric(cell.Value) And cell.Value > 0 Then
Application.EnableEvents = False
cell.Offset(0, 1) = cell / Range("G3")
cell.Offset(0, 2) = cell / Range("H3")
Range("E11") = Range("F11") * Range("G3")
Range("G11") = Range("E11") / Range("H3")
cell.Offset(0, -1) = Range("H3")
cell.Offset(0, -2) = Range("G3")
cell.Offset(0, -3) = Date
Else
Application.EnableEvents = False
cell.Offset(0, 0) = "0"
cell.Offset(0, 1) = "0"
cell.Offset(0, 2) = "0"
cell.Offset(0, -1) = ""
cell.Offset(0, -2) = ""
cell.Offset(0, -3) = ""
End If
Next cell
Application.EnableEvents = True 'reenable events
End Sub