Copy cell value via VBA if specific cell is changed

Schturman

Board Regular
Joined
May 28, 2022
Messages
63
Office Version
  1. 2019
Platform
  1. Windows
Hi to all
I need some help to change the code that I use to copy value...
This code I use:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range

 If Not Intersect(Target, Range("B2")) Is Nothing Then
  Set rng = Range("C2")
  rng.Value = Range("A2")
    Else
    If Not Intersect(Target, Range("B3")) Is Nothing Then
     Set rng = Range("C3")
     rng.Value = Range("A2")
     End If
  End If

End Sub
1680284474739.png


If I do any changes to B2, it will copy A2 to C2
If I do any changes to B3, it will copy A2 to C3
And so on...

When I add new row (for example insert value to B4), I need to update my code that will do the same copy to C4
Can someone help me to change the code that will do what I want without every time updating VBA code ?
Thanks
 
Ok, I fixed the zeroes appearing :)
I changed this line in code:
Code:
If IsNumeric(cell.Value)
to this one:
Code:
If IsNumeric(cell.Value) And cell.Value > 0 Then
Now I can drag numbers and it can calculate, I can drag text without errors and I can delete content without zeroes appearing 😁
Thank you very much !!!
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,223,702
Messages
6,173,961
Members
452,539
Latest member
delvey

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