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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
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,224,814
Messages
6,181,126
Members
453,021
Latest member
Justyna P

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