One More Try To Run This Macro With A Formula

rockyw

Well-known Member
Joined
Dec 26, 2010
Messages
1,196
Office Version
  1. 2010
Platform
  1. Windows
I have this code..
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("E3")) Is Nothing Then Macro
    Sheets("Sheet3").Select
    Range("E3:E24").Select
    Selection.Copy
    Sheets("Sheet2").Select
    Range("E3:E24").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
End Sub

Can I make this run when a cell or some cells in a range of cells (sheet 3 E3:E24) gets filled by a formula? This works when I use a command button but I would like it to just run when the other cells get filled. I seen a lot of ideas but none work, can an IF formula make a macro run? Thanks
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try putting this in Sheet3's code module

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim keyRange As Range
    Set keyRange = Range("E3:E24")
    On Error Resume Next
    Set keyRange = Application.Union(keyRange, keyRange.Precedents)
    On Error GoTo 0
    If Not Application.Intersect(Target, keyRange) Is Nothing Then
        With Range("E3:E24")
            ThisWorkbook.Sheets("Sheet2").Range(.Address).Value = .Value
        End With
    End If
End Sub
 
Upvote 0
I just will not run by it's self. I can run it manually but it will not fire on it's own. Thanks but I guess I will have to keep a command button for the macro. Have you ever seen this work on other workbooks? Thanks for your help.
 
Upvote 0
I just will not run by it's self. I can run it manually but it will not fire on it's own.
It sounds like you have not installed the Mike's code in the correct place. Event code does not go in the same module as macros do; rather, it goes in the worksheet module for the sheet that you want to monitor. Look over in the Project Window and locate the Sheet3 entry... double click it... that will open up a code window... put Mike's code in that code window and it will run automatically when changes are made to the cells being monitored.
 
Upvote 0
What do you actually want to do?

Is this code meant to be triggered when a formula is put in E3?

Or when the result of a formula in E3 changes?
 
Upvote 0
HTML:
Or when the result of a formula in E3 changes?

When the result of the formula changes in E3 thru E24. It may be every cell, it may just change in half of them depending on inventory. That's what I have been trying to say, I must not have made that clear. I paste a report on sheet 1, formulas on sheet 3 E3:E24 look for data and return it to sheet 3 E3:E24, then this macro copys and pastes sheet 3 E3:E24 and paste special (value only) in sheet 2 E3:E24. That make sence? Can this macro still be ran some how by it' self? Thanks
 
Upvote 0
Again, thanks for your help and sorry if I am not clear on what I am trying to do. I have a workbook that uses 3 sheets. I run a report, this covers A-V or more, rows 1-540 or more. I copy this, open the workbook I am working on now and paste the report on sheet 1. On sheet 3 I have these formulas in E3:E24 that look for item numbers and sum the totals back to E3:E24. The formulas are as follows...
Code:
=SUM(SUMIF(Sheet1!P:P,{"651102*"},Sheet1!B:B))
I then use the macro to copy and paste the values from sheet 3, E3:E24 to Sheet 2, E3:E24. I do this because it's the only way I can keep the condistional formating working correctly on sheet 2. If I put a formula directly on sheet 2, the formating sees the formuals and will not work correctly, so I use the macro to copy, paste special the values from sheet 3 to sheet 2. I would like to just paste the report on sheet one, the formulas put the values in sheet 3, and I would like the macro to copy the values from sheet 3 to sheet 2 without any buttons or acts to run the macro. I am making this, others will use it. I'm trying to make it as simple as I can. Thanks
 
Upvote 0
The condisional formating on sheet 2 is, =E3="" I want the text to be white ( I can't see it) until a value is there, then the text turns black and I can see the discription. If I put a formula in there the condistional format sees the formula and thinks it's a value. The macro copy paste special is the only way I know to do this. Thanks
 
Upvote 0
Put this in Sheet1's code module

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Application.Intersect(Target, Range("P:P,B:B") Is Nothing Then
        With ThisWorkbook
            .Sheets("Sheet2").Range("E3:E24")).Value = .Sheets("Sheet3").Range("E3:E24")).Value
        End With
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,903
Members
452,948
Latest member
Dupuhini

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