Division of cells using cells(ij) format

keerthi4786

New Member
Joined
Mar 28, 2019
Messages
6
Hi everyone, I want to divide respective cells in one column with other column and obtaining the results in next column using cells reference. Here is VBA code i am using
Range(Cells(3, lastcolumn + 6), Cells(5, lastcolumn + 6)).Formula = "=" & Cells(3, lastcolumn + 4) & "/" & Cells(3, lastcolumn + 5)

It is giving same value for all cells it will not dividing respective cells.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
What is "lastcolumn"?
Normally one assumes that it would be the last used column.
 
Upvote 0
Code:
"=" & Cells(3, lastcolumn + 4) & "/" & Cells(3, lastcolumn + 5)
If "lastcolumn" is the last column to have data then certainly "lastcolumn + 4" and "lastcolumn + 5" must be empty Columns. Or am I missing something?
 
Upvote 0
If I were putting a formula in those cells, I would do somehting like
Code:
Range(Cells(3, lastcolumn + 6), Cells(5, lastcolumn + 6)).FormulaR1C1 = "=RC[-2]/RC[-1]"
 
Last edited:
Upvote 0
Try this and see what the formula says. Adjust/Change references as required.
Code:
Sub Maybe()
Dim lc As Long
lc = Cells.Find("*", , , , xlByColumns, xlPrevious).Column
    Range(Cells(1, lc + 1), Cells(25, lc + 1)).Formula = "=RC[-2]/RC[-1]"
End Sub

Mike was just a couple steps faster.
 
Upvote 0

Forum statistics

Threads
1,215,488
Messages
6,125,092
Members
449,206
Latest member
ralemanygarcia

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