How to activate VBA in the sheet without F5

Status
Not open for further replies.

McM_

New Member
Joined
Oct 23, 2023
Messages
23
Office Version
  1. 365
Platform
  1. Windows
Hello, please, a code that automatically activates the formulas in the sheet, without the need to activate Macros with F5. In Example 1 I took a simple formula just to see the code that automatically activates the formulas in the sheet.
In examples 2 and 3, I have codes that are automatically activated in the sheet when a condition is met.
Thank you!

VBA Code:
Sub Macrocomandã5()

    Range("C2:C8").Select
    ActiveCell.FormulaR1C1 = "=IF(RC[-2]>0,(RC[-2]+RC[-1]),"""")"
    Range("C2:C8").Select
    Range("C3").Activate
    
End Sub

Private Sub worksheet_Change(ByVal Target As Range)
Dim ws As Worksheet

If Target.Column = 5 Then
Range("F" & Target.Row) = Now
End If

If Target.Column = 10 Then
Range("I2:I" & Target.Row) = Range("H2")
End If

End Sub
VBA.xlsm
ABCDEFGHIJK
1didn`t workworkworkwrite here
2123fdgf28.10.2023 08:20testtestjhkhj
334didn`t workfdgfd28.10.2023 08:20testjk
459didn`t workdfgd28.10.2023 08:20testhkh
54didn`t worktesthkh
6didn`t work
7didn`t work
8 
9
10EXAMPLE 1EXAMPLE 2EXAMPLE 3
11 
Foaie1
Cell Formulas
RangeFormula
C2,C11,C8C2=IF(A2>0,(A2+B2),"")
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Duplicate to: VBA activate Sheet in Excel

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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