Subtract two Columns(A-B) result in ColumnC (using Scripting.Dictionary)

marreco

Well-known Member
Joined
Jan 1, 2011
Messages
609
Office Version
  1. 2010
Platform
  1. Windows
hi.

I try learning about Scripting.Dictionary.
My question is:
How subtract two Columns(A-B) result in ColumnC (using Scripting.Dictionary).

<colgroup><col style="mso-width-source:userset;mso-width-alt:2194;width:45pt" width="60"> <col style="mso-width-source:userset;mso-width-alt:2230;width:46pt" width="61"> <col style="mso-width-source:userset;mso-width-alt:1865;width:38pt" width="51"> </colgroup><tbody>
[TD="class: xl65, width: 60"]Col A[/TD]
[TD="class: xl65, width: 61"]Col B[/TD]
[TD="class: xl65, width: 51"]Col C[/TD]

[TD="class: xl65, align: right"]29,06[/TD]
[TD="class: xl65, align: right"]38,05[/TD]
[TD="class: xl65, align: right"]-8,99[/TD]

[TD="class: xl65, align: right"]19,09[/TD]
[TD="class: xl65, align: right"]25,00[/TD]
[TD="class: xl65, align: right"]-5,91[/TD]

[TD="class: xl65, align: right"]29,00
[/TD]
[TD="class: xl65, align: right"]37,17[/TD]
[TD="class: xl65, align: right"]-8,17[/TD]

[TD="class: xl65, align: right"]29,74[/TD]
[TD="class: xl65, align: right"]38,12[/TD]
[TD="class: xl65, align: right"]-8,38[/TD]

[TD="class: xl65, align: right"]29,00[/TD]
[TD="class: xl65, align: right"]37,17[/TD]
[TD="class: xl65, align: right"]-8,17[/TD]

[TD="class: xl65, align: right"]25,76[/TD]
[TD="class: xl65, align: right"]34,24[/TD]
[TD="class: xl65, align: right"]-8,48[/TD]

[TD="class: xl65, align: right"]38,43[/TD]
[TD="class: xl65, align: right"]51,09[/TD]
[TD="class: xl65, align: right"]-12,66[/TD]

[TD="class: xl65, align: right"]38,44[/TD]
[TD="class: xl65, align: right"]51,09[/TD]
[TD="class: xl65, align: right"]-12,66[/TD]

[TD="class: xl65, align: right"]39,55[/TD]
[TD="class: xl65, align: right"]52,57[/TD]
[TD="class: xl65, align: right"]-13,02[/TD]

[TD="class: xl65, align: right"]21,58[/TD]
[TD="class: xl65, align: right"]28,68[/TD]
[TD="class: xl65, align: right"]-7,10[/TD]

[TD="class: xl65, align: right"]22,52[/TD]
[TD="class: xl65, align: right"]29,93[/TD]
[TD="class: xl65, align: right"]-7,41[/TD]

[TD="class: xl65, align: right"]114,62[/TD]
[TD="class: xl65, align: right"]148,01[/TD]
[TD="class: xl65, align: right"]-33,39[/TD]

</tbody>
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
You wouldn't use a dictionary for something like that.
If you want to subtract one value from another with VBA, try
Code:
Sub marreco()
   With Range("C2", Range("B" & Rows.Count).End(xlUp).Offset(, 1))
      .Value = Evaluate("if({1}," & .Offset(, -2).Address & "-" & .Offset(, -1).Address & ","""")")
   End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,340
Members
452,638
Latest member
Oluwabukunmi

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