Excel VBA - I need to multiply two cells

How can i multiply the price and qty and let it enter the  value in the total column? i want it to be only one code cause i am going to use a button

Thanks,
Ahmad Abbas
2015-10-30_130541.png
Ahmad AbbasAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Assign the following code to a Shape or a Button (Form Control) so that when the button is clicked, the code will be executed.
Sub GetTotal()
Dim lr As Long
Dim rng As Range, cell As Range

lr = Cells(Rows.Count, 2).End(xlUp).Row
Set rng = Range("B2:B" & lr)
For Each cell In rng
   If IsNumeric(cell) And cell <> "" Then
      cell.Offset(0, 2) = cell * cell.Offset(0, 1)
   End If
Next cell
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ahmad AbbasAuthor Commented:
Sorry but like i didin't get it i want it to multiply qty and price and put them in the total column
0
Ahmad AbbasAuthor Commented:
Nvm and tyvm for helping me!!!
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Ahmad AbbasAuthor Commented:
It worked
0
Ahmad AbbasAuthor Commented:
Last question can u explain to me that code?

Thanks,
Ahmad Abbas
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
The code looks at values in column B starting from row2 to the last cell with value in column B and if the value in a cell in column B is numeric and is not blank, it multiplies the value in column B with value in column C and places the result in column D in the  corresponding row.

So if column B contains a text string or it is blank i.e. doesn't contain a qty in it, the code will overlook that cell.
1
Ahmad AbbasAuthor Commented:
Thanks
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome Ahmad! Glad I could help.
0
Ahmad AbbasAuthor Commented:
can i ask you for ur email or skype or anything where i can contact u if i needed help?
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Just sent you a Private Message with my Email Id.
0
Ahmad AbbasAuthor Commented:
Thanks
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
My Pleasure Ahmad!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.