addinf formula via VBA

JeremyGraham95

New Member
Joined
Jan 12, 2016
Messages
19
i am working on an inventory spreadsheet and am trying to finish out the last couple tasks.I am trying to enter a formula "A3-B3 from sheet 1" and paste it in sheet 2. and i want to do the whole column which goes down to A128.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
This assumes you want to start in A1 on sheet 2 since you didn't specify.

It also assumes there's a space between the word sheet and the number as you show in your example.

If anything is different you will have to adjust the code or you will get an error.

Code:
Sub Test()
    With Worksheets("Sheet 2")
        .Range("A1:A128").Formula = "='Sheet 1'!A3-'Sheet 1'!B3"
    End With
End Sub
 
Upvote 0
I would be starting in the first empty column on the worksheet "sheet 2". but i actually need the code to find the last 2 columns and use that formula for those 2 columns.
 
Upvote 0

Forum statistics

Threads
1,216,098
Messages
6,128,812
Members
449,468
Latest member
AGreen17

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