Formula with VBA problem

luizmachado

New Member
Joined
Dec 15, 2015
Messages
11
I have this code where I want get the entire value from a division, for example 7/2 gives me 3.5, not 3 (as the quotient function would give me). It works separately (on the fx line), but I need this to refresh automatically every time some data changes.
It won't go further because of this comma "," between the cells. I don't know what to do to fix it. Do you guys have any idea of what I can do?


Sub Division()
Dim LastRow As Long

LastRow = Cells(Cells.Rows.Count, "I").End(xlUp).Row
Range("I" & LastRow).Formula = "=sum((quotient(E" & LastRow - 1 & ", F" & LastRow - 1 & "), (mod(E" & LastRow - 1 & ",F" & LastRow - 1 & ")/F" & LastRow - 1 & "))"
End Sub

eNoozng.png


 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
you need to call Division, from a Worksheet_Change Event in the macro

you'll probably want to reduce that down to just a column or a few cells when you have tested
 
Upvote 0
How do I do it? Im kinda new in this VBA thing haha

But would that solve my problem? Because when I try to run it, I get the comma between cells indicators (E" & LastRow - 1 & ", F" & LastRow - 1 & ") selected. I guess that would be the problem.
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,194
Members
449,072
Latest member
DW Draft

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