VBA Help...

Jav_uk8

New Member
Joined
Jan 12, 2017
Messages
22
Hi All,

VBA help

I have a total column in row 664 (this will be variant week to week)

I need the VBA to calculate L664 / K664 but like I mentioned the above, it will not be fixed to this row every week.

What I have so far is:

Range("N1").End(xlDown).End(xlDown).Offset(2, 0).Select
ActiveCell.FormulaR1C1 = "% of Collection Rate"

Range("O1").End(xlDown).End(xlDown).Offset(2, 0).Select

Hope this makes sense?

Cheers

Jav
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Perhaps.
Code:
    .Value = "% of Collection Rate"
    .Offset(, 1).FormulaR1C1 = "=R[-2]C[-3]/R[-2]C[-4]"
End With
 
Upvote 0
How about something like
Code:
Sub DivTotals()
   With Range("L" & Rows.Count).End(xlUp)
      .Offset(, 3).Value = .Value / .Offset(, 1).Value
   End With
End Sub
 
Upvote 0
Oops, kind of missed an important part - the first line of the code.:eek:
Code:
With Range("N" & Rows.Count).End(xlUp).Offset(2, 0)
    .Value = "% of Collection Rate"
    .Offset(, 1).FormulaR1C1 = "=R[-2]C[-3]/R[-2]C[-4]"
End With
 
Upvote 0
Hi Fluff / Norie,

Unfortunately neither work - For this week the formula will be in cell 0666 (which will be the sum L664 / K664)

 
Upvote 0
How did the posted code no work?

Errors?

Formulas/values not going where expected?
 
Upvote 0
Hi Norie,

I have got the formula to work!!! :)

My problem now is how do I format the cell into a percentage cell?

My VBA is below:

With Range("M" & Rows.Count).End(xlUp).Offset(2, 0)
.Value = "% of Collection Rate"
.Offset(, 1).FormulaR1C1 = "=R[-2]C[-2]/R[-2]C[-3]"
 
Upvote 0
Try this, change the formatting. e.g decimal places, as required.
Code:
With Range("M" & Rows.Count).End(xlUp).Offset(2, 0)
    .Value = "% of Collection Rate"
    With .Offset(, 1)
        .FormulaR1C1 = "=R[-2]C[-2]/R[-2]C[-3]"
        .NumberFormat = "0.00%"
    End With
End With
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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