How use RC formulas when fill three columns

Abdo

Board Regular
Joined
May 16, 2022
Messages
220
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Hello
I have this code.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim lr As Long
    If Target.Address = Range("G2").Address Or Target.Column = 5 Or Target.Column = 6 Then
        Application.EnableEvents = False
        lr = Cells(Rows.Count, "B").End(xlUp).Row

        Range("G2").FormulaR1C1 = "=RC[-2]-RC[-1]"
        Range("G3:G" & lr).FormulaR1C1 = "=R[-1]C+RC[-2]-RC[-1]"
        Range("G3:G" & lr).Value = Range("G3:G" & lr).Value
        Application.EnableEvents = True
    End If

End Sub
I try when fill column E or F then will fill two formula
in G2=E2-F2
G3=G2+E3-F3
G4=G3+E4-F4
and so on .
the code will show error in G2,G3 =#VALUE
any help guys,please?
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
What do the formulas
Excel Formula:
=ISNUMBER(E2)
and
Excel Formula:
=ISNUMBER(F2)


return?
 
Upvote 0
Also what do the formulas
Excel Formula:
=CODE(E2)
=UNICODE(E2)
=CODE(F2)
=UNICODE(F2)

Return?
 
Upvote 0
ISNUMBER gives true
CODE gives 50
UNICODE gives #NAME?
There should be 6 answers so you there are 3 missing (2 now as you can ignore the unicode formula as you are using your 2010 version)

The Name error will be because you are using your 2010 version and not your 2019 version
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top