Creating a macro - Your assistance please

Slinky1233

New Member
Joined
Apr 1, 2011
Messages
2
Hi
I am looking for a bit of help with a macro I am thinking of creating.
Basically I am working with 2 sheets (sheet1 and sheet2).
sheet1 is the master data sheet.
sheet2 is a simple calculation results sheet.
This idea is I use sheet2 to get a result that needs to be subtracted from a range in sheet1.
I currently use vlookup to scan the range in sheet1 to find the value in A1 sheet2.
Once it has found the matching value in the range, minus the result in A2 sheet2 from it.
I would like to activate the calculation on a button click in sheet2.
I am just a novice in creating macros but am pretty up to speed using excel functions.
Sorry if I haven't made myself clear.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Welcome to the board. Can you post your formula please?
 
Upvote 0
Thanks for your reply.
Here is part of the calculation formula in cell D6 in sheet 2.
=IF(ISBLANK(B6),"",IF(B6>0,VLOOKUP(B6,Sheet1!$A$1:$D$10,4,FALSE),""))
Then in cell E6 I have this formula for the result calculation =IF(ISBLANK(A6),"",D6-(A6*$C$4))
 
Upvote 0
Create a button and attach this to the code of the button:
Code:
Sub MyCalculate ()
Sheets("Sheet2").Select
Range("D6").Formula = "=IF(ISBLANK(B6),"""",IF(B6>0,VLOOKUP(B6,Sheet1!$A$1:$D$10,4,0),""""))"
Range("E6").Formula = "=IF(ISBLANK(A6),"""",D6-(A6*$C$4))"
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,632
Members
452,933
Latest member
patv

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