Make the worksheet dynamic

kvemperor

New Member
Joined
Jan 13, 2023
Messages
31
Office Version
  1. 2021
Platform
  1. Windows
sample.jpg

In this worksheet i have the function in cell G9 =B9+G8-E9 so every time i am putting a value in the column B or in the column E then when i drag down the cell (of the same row)in the column G then i have my result.Is it possible this to make it dynamic?(with vba or any other way? i mean instead of drugging down the cell of the column G down when i am putting a value in the column B or in the column E the result comes automatically in the column G.
I wouldn't mind when i was putting the date in the column F then automatically comes the result in the column G
thank you in advance
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Nο🥺 .now i put the values in the columns D and G instead of the columns C and F .I am also putting something to the column E but its an other thing
so why you didn't say that from the beginning as I ask you many times?
just post the whole requirements without any adjusting every time until to find help from the rest of others members.
and which you columns entering ?
just I want if you want enter values in columns C ,F as in earlier
anyway try this and see how goes .
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Or Target.Row < 8 Then Exit Sub
Application.EnableEvents = False
If Target.Column = 5 And Target.Row > 8 Or Target.Column = 7 And Target.Row > 8 Then
Dim LR1 As Integer
LR1 = Range("B" & Rows.Count).End(xlUp).Row
For s = 9 To LR1
Range("I9:I" & s).FormulaR1C1 = "=RC[-6]+R[-1]C-RC[-3]"
Next
End If
Application.EnableEvents = True
End Sub
 
Upvote 1
Hallo my friend.Still no working :cry:
sorry buddy!
seems wrong in this line
VBA Code:
Range("I9:I" & s).FormulaR1C1 = "=RC[-6]+R[-1]C-RC[-3]"
just change this
VBA Code:
Range("I9:I" & s).FormulaR1C1 = "=RC[-6]+R[-1]C-RC[-3]"
to this
VBA Code:
Range("I9:I" & s).FormulaR1C1 ="=RC[-4]+R[-1]C-RC[-2]"
then will become
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Or Target.Row < 9 Then Exit Sub
Application.EnableEvents = False
If Target.Column = 5 And Target.Row > 8 Or Target.Column = 7 And Target.Row > 8 Then
Dim LR1 As Long
LR1 = Range("B" & Rows.Count).End(xlUp).Row
For s = 9 To LR1
Range("I9:I" & s).FormulaR1C1 = "=RC[-4]+R[-1]C-RC[-2]"
Next
End If
Application.EnableEvents = True
End Sub
if the calculation is wrong , just tell me how the formula should be .
 
Upvote 1
Upvote 0
So you have converted the area into a table and can see the table design tab on the toolbar, and copied the formula to all rows initially and it still doesn't do what you want ?
 
Upvote 0
So you have converted the area into a table and can see the table design tab on the toolbar, and copied the formula to all rows initially and it still doesn't do what you want ?
yes my friend.it writes value instead of the result
 
Upvote 0
@kvemperor
I'm not sure if I understand your OP
but I supposes in G8 will contain value and from G9 will add formula . if you want just showing value not formula in column G ,then enable the line disabled as in comment inside the code
so this my try .
copy the code and paste into sheet module , not standard module
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Or Target.Row < 1 Then Exit Sub
Application.EnableEvents = False
If Target.Column = 2 And Target.Row > 1 Or Target.Column = 5 And Target.Row > 1 Then
lr = Range("B" & Rows.Count).End(xlUp).Row
Range("G9:G" & lr).FormulaR1C1 = "=RC[-5]+R[-1]C-RC[-2]"
'if  you  don't  show  formula in column G then enable this  line 
'Range("G9:G" & lr).Value=Range("G9:G" & lr).Value
End If
Application.EnableEvents = True
End Sub
I hope this help you.
 
Upvote 0
@kvemperor
I'm not sure if I understand your OP
but I supposes in G8 will contain value and from G9 will add formula . if you want just showing value not formula in column G ,then enable the line disabled as in comment inside the code
so this my try .
copy the code and paste into sheet module , not standard module
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Or Target.Row < 1 Then Exit Sub
Application.EnableEvents = False
If Target.Column = 2 And Target.Row > 1 Or Target.Column = 5 And Target.Row > 1 Then
lr = Range("B" & Rows.Count).End(xlUp).Row
Range("G9:G" & lr).FormulaR1C1 = "=RC[-5]+R[-1]C-RC[-2]"
'if  you  don't  show  formula in column G then enable this  line
'Range("G9:G" & lr).Value=Range("G9:G" & lr).Value
End If
Application.EnableEvents = True
End Sub
I hope this help you.
Thank you very much my friend for your answer. I will try it tomorrow and I will let you know
 
Upvote 0
@kvemperor
I'm not sure if I understand your OP
but I supposes in G8 will contain value and from G9 will add formula . if you want just showing value not formula in column G ,then enable the line disabled as in comment inside the code
so this my try .
copy the code and paste into sheet module , not standard module
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Or Target.Row < 1 Then Exit Sub
Application.EnableEvents = False
If Target.Column = 2 And Target.Row > 1 Or Target.Column = 5 And Target.Row > 1 Then
lr = Range("B" & Rows.Count).End(xlUp).Row
Range("G9:G" & lr).FormulaR1C1 = "=RC[-5]+R[-1]C-RC[-2]"
'if  you  don't  show  formula in column G then enable this  line
'Range("G9:G" & lr).Value=Range("G9:G" & lr).Value
End If
Application.EnableEvents = True
End Sub
I hope this help you.
Hallo my friend.i tried this but something is wrong and i can not do it properly.
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,215,133
Messages
6,123,235
Members
449,092
Latest member
SCleaveland

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