Running macro when cell is changed

johnpants

New Member
Joined
Oct 31, 2005
Messages
44
Hello, i'm trying to get a macro to run that will copy columns I, J, K and L and paste the values into M, N, O and P if any of the cells S5:S9 are changed.

Is this possible? Could anyone help please?

Thank you,

John.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Right click on the tab of the sheet of interest, select "view code", and paste this:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, [S5:S9]) Is Nothing Then [I:L].Copy [M:P]
End Sub
 
Upvote 0
Brilliant, that's exactly what I want it to do. One small thing, could I add a PasteSpecial command in there so it only pastes the values?

Thank you for your help, it's much appreciated.
 
Upvote 0
Try this:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Not Intersect(Target, [S5:S9]) Is Nothing Then
[I:L].Copy
[M:P].PasteSpecial (xlValues)
Application.CutCopyMode = False
Target.Activate
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,981
Members
448,538
Latest member
alex78

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