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

Aviles

Board Regular
Joined
Dec 17, 2008
Messages
165
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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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