How use RC formulas when fill three columns

Abdo

Board Regular
Joined
May 16, 2022
Messages
228
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

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
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?
 
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
Please can you upload a copy of your workbook to a free (the non-business versions) file hosting site like www.box.com or www.dropbox.com.
Sanitize any sensitive data before uploading
Remember to mark the file for sharing and then paste the link it provides in the thread.
 
Upvote 0
Please can you upload a copy of your workbook to a free (the non-business versions) file hosting site like www.box.com or www.dropbox.com.
ok, now I'm at work and version 2016 and works, but at my home version is 2010 and shows error .
so when come back home about after 4 hours at least I will upload the file.
 
Upvote 0

Forum statistics

Threads
1,224,847
Messages
6,181,325
Members
453,032
Latest member
Pauh

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