Can I transform a Worksheet_Change event in a normal macro?

gubertu

Board Regular
Joined
May 24, 2015
Messages
147
Hi all,

I have the following code. This is a Worksheet_Change event and I would like to know if it is possible to modify this code so I can execute it when I want, as a normal macro, pressing F5.

Thanks in advance!


VBA Code:
Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("BV1:BV" & Range("CJ" & Rows.Count).End(xlUp).Row)) Is Nothing Then
    Application.ScreenUpdating = False
    With Sheets("SYS Agregado")
        For MY_ROWS = 2 To .Range("CJ" & Rows.Count).End(xlUp).Row
                If .Range("CJ" & MY_ROWS).Value & .Range("CL" & MY_ROWS).Value = _
                    .Range("CJ" & Target.Row).Value & .Range("CL" & Target.Row).Value Then
                        MY_TOTAL = MY_TOTAL + .Range("BV" & MY_ROWS).Value
                End If
        Next MY_ROWS
        Sheets(.Range("CJ" & Target.Row).Value).Range(.Range("CL" & Target.Row).Value).Value = MY_TOTAL
    End With
    Application.ScreenUpdating = True
    End If
End Sub
 
ScreenShot001.png
Cool! Good to know.

Never tried that before. But I also seldom use User Forms in Excel (If I need user forms, I usually opt for Microsoft Access).
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,215,036
Messages
6,122,794
Members
449,095
Latest member
m_smith_solihull

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