## Microsoft Excel subtraction using VBA  Tags:
Microsoft Excel
Microsoft Excel formulas
VBA
I would like to have some coding in vb related to subtraction in Excel sheet.I have 2 sheets.I need to take data from 2 cells from the first sheet and perform subtraction and then placeresult in sheet2.I have huge amount of data in sheet1.I need to perform this operation with all the cells in sheet1.By clicking a button it should give all results at a time.Can you please provide me the sample code.

Thanks. We'll let you know when a new response is added.

I am supposing that you have a data in sheet1 and you want result in sheet2. Also, the data is lying in A and B column of sheet1. So the following code will help you in achieving results.

```Sub SubExample()
Dim i as long

i=1
Do while Sheet1.Cells(i,1)<>""
Sheet2.Cells(i,1)= Sheet1.Cells(i,1)-Sheet1.Cells(i,2)

i=i+1
Loop

End Sub```

Regards,
Sarfaraz Ahmed

## Discuss This Question: 1 Reply

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
• Hi, Thank you.The basic operation is excel subtraction but the actual problem is: I have 3 excel sheets. In sheet1 I have huge amount of data in date & time(date-hourse:min:sec:millisec) formate.I need to exclude date formate and take only time formate(hourse:min:sec:millisec) and place that data in sheet2. So now In sheet2 we have number of rows from B to k and columns from 1 to 1000 all these cells consists data in time formate.I need to take all the data in B row as a reference data and subtract B row data from C row data and place all the result in sheet3.similarly perform this subtraction with each row(D,E,F...........K)by taking B as a reference row and place the results in corresponding cells of sheet3.all these operations should be done at a time by clicking the button in sheet1.
report 