Error with Loop

Jeeremy7

Board Regular
Joined
May 13, 2020
Messages
110
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a problem with one of the loop I'm trying to do and I think it's in the formula but could somoene help me ?
Also I saw that some macro run faster without Loop, is there a way to convert my code without loop ?

Here the code thanks !
VBA Code:
   'Put the total cost plus fee at the end of each code
    Dim A As Long
    Dim B As Integer
    A = ActiveCell.Offset(0, -2)
    B = Sheets("Notes").Range("B1")
    
    Range("K13").Select
    Do Until ActiveCell.Offset(0, -8) = "Total"
        If ActiveCell.Offset(1, -2) = "" Then
            ActiveCell = A * (1 + B)
        Else
            ActiveCell.Offset(1, 0).Select
        End If
    Loop
    
End Sub
 
Ok, how about
VBA Code:
Sub Jeeremy()
   Dim Rng As Range
   
   For Each Rng In Range("J5", Range("J" & Rows.Count).End(xlUp)).SpecialCells(xlConstants).Areas
      If Rng.Count = 1 Then
         Rng.Offset(, 1).FormulaR1C1 = "=rc[-2]*(1+Notes!r1c2)"
      Else
         Rng.Offset(Rng.Count, 1).Resize(1).FormulaR1C1 = "=rc[-2]*(1+Notes!r1c2)"
      End If
   Next Rng
End Sub
 
Upvote 0
Solution

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,666
Members
448,977
Latest member
moonlight6

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