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 Formula()

    'I want this code to run without F5
    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

'activation without F5
If Target.Column = 8 Then
Range("I" & Target.Row) = Now
End If

If Target.Column = 14 Then
Range("M3:M" & Target.Row) = Range("L3")
End If

End Sub
 

Attachments

  • Capture.JPG
    Capture.JPG
    79.4 KB · Views: 5

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I added the table
VBA.xlsm
ABCDEFGHIJKLMNO
1Example 1Example 2Example 3
2it only works with F5 activationit works without activating F5it works without activating F5write here
3123it only works with F5 activationabc27.10.2023 10:14testtestyyt
434didn't workcda27.10.2023 10:14testgghfh
559didn't workbac27.10.2023 10:14testghgh
64didn't workabd27.10.2023 10:15testyuyu
728.10.2023 05:39
8
9
10
11
12
13
14
15
16 
17 
18 
Foaie1
Cell Formulas
RangeFormula
C3,C16:C18C3=IF(A3>0,(A3+B3),"")
 
Upvote 0
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,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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