Find last cell in column and divide by the last cell in aother column

Aviles

Board Regular
Joined
Dec 17, 2008
Messages
163
Hi all,

I'm looking for a vba solution that finds the last cell in column Q and divides it by the last cell in column N. The last cells in column Q & N have sums for each column.

I would then like to return this value in the last empty cell in column P.

I know how to find the last cells in a column but I can't quite figure out how to divide it by another.

Thanks in advance.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Code:
Sub Aviles()
Cells(Rows.Count, "P").End(xlUp).Offset(1).Value = Cells(Rows.Count, "Q").End(xlUp).Value / Cells(Rows.Count, "N").End(xlUp).Value
End Sub
 
Upvote 0
Code:
Sub Aviles()
Cells(Rows.Count, "P").End(xlUp).Offset(1).Value = Cells(Rows.Count, "Q").End(xlUp).Value / Cells(Rows.Count, "N").End(xlUp).Value
End Sub

Thank you, that works great!

One last question: how do I get the value returned in column P to be formatted to one decimal place? (NumberFormat = "0.0")
 
Upvote 0
You are welcome - thanks for the reply.

Try this modification for the formatting you want.
Code:
Sub Aviles()
With Cells(Rows.Count, "P").End(xlUp).Offset(1)
    .Value = Cells(Rows.Count, "Q").End(xlUp).Value / Cells(Rows.Count, "N").End(xlUp).Value
    .NumberFormat = "0.0"
End With
End Sub
 
Upvote 0
You are welcome - thanks for the reply.

Try this modification for the formatting you want.
Code:
Sub Aviles()
With Cells(Rows.Count, "P").End(xlUp).Offset(1)
    .Value = Cells(Rows.Count, "Q").End(xlUp).Value / Cells(Rows.Count, "N").End(xlUp).Value
    .NumberFormat = "0.0"
End With
End Sub

That's perfect, thanks again!
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,140
Members
448,551
Latest member
Sienna de Souza

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