Insert Formula using VBA

dannyok90

Board Regular
Joined
Aug 30, 2016
Messages
115
Hi All,

I'm wondering if its possible to insert a formula into a cell based on other cells.


In columns A, B and C i have a formula dragged down to row 10000 that gets information from a data set that starts in D1. It's taking up alot of memory and causing the spreadsheet to calculate slowly


I paste data in D1 and the data grows week on week so i just keep pasting it over d1. I was thinking I could use vba to insert a formula into A B & C that would populate as the data set grows, that way there would only be formulas in the rows upto the end of the data set. so the spreadsheet wouldn't be so slow?


Help appreciated :)

Dan
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Dan

Do you mean that whenever data is entered in column D the formulas in columns A, B & C are copied down?
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Column = 4 Then
        Application.EnableEvents = False
        Intersect(Range("A1:C1").EntireColumn, Rows(Target.Row - 1)).Copy Target.Offset(, -3).Resize(Target.Rows.Count)
        Application.EnableEvents = True
    End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,244
Members
452,622
Latest member
Laura_PinksBTHFT

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