VBA activate Sheet in Excel

McM_

New Member
Joined
Oct 23, 2023
Messages
23
Office Version
  1. 365
Platform
  1. Windows
Hello
I know this is a beginner problem, but is there anyone who can help me with the information below?
How to activate VBA that launches a formula from the Sheet, and that formula to run C3:C100, without the need to launch with F5?
In the end, I managed to display the date under certain conditions, without needing to activate it with F5.
I can't find how to activate the formulas without F5.
Please excuse the technical terms.
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 SubPrivate Sub worksheet_Change(ByVal Target As Range)Dim ws As WorksheetIf Target.Column = 8 ThenRange("I" & Target.Row) = NowEnd IfIf Target.Column = 14 ThenRange("M2:M" & Target.Row) = Range("L2")End IfEnd Sub
 

Attachments

  • Capture.JPG
    Capture.JPG
    42 KB · Views: 9
From the example in the table, the macro is activated only on C3.
I need it to be activated on the whole C column
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I come with clarifications.
Now, if cell B3 is completed, trigger the macro with the formula and the result is in C3.
I need if B4 is completed, the formula should calculate in C4, B4-A4;
Completed B5, B5-A5, and so on for the rows that meet the condition in the formula.
Thank you for your time!

VBA Code:
Sub Formula()

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

VBA.xlsm
ABCDE
2
3132
434didn't work
559didn't work
656didn't work
7
8 
9 
10
11 
12
Foaie1
Cell Formulas
RangeFormula
C3,D11,C8:C9C3=IF(ISNUMBER(B3),B3-A3,"")
 
Upvote 0
If I understood what you just posted then perhaps:

Book2
ABC
2Col ACol BResult
3134
4347
55914
65611
Sheet1
Cell Formulas
RangeFormula
C3:C6C3=IF(A3>0,(A3+B3),"")


VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rng As Range

    With Me
        Set rng = .Range("A3:B" & .Range("A" & .Rows.Count).End(xlUp).Row)
    End With

    If Not Application.Intersect(rng, Target) Is Nothing Then
        With rng.Offset(0, 2).Resize(, 1)
            .FormulaR1C1 = "=IF(RC[-2]>0,(RC[-2]+RC[-1]),"""")"
        End With
    End If
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,895
Messages
6,175,257
Members
452,625
Latest member
saadat28

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