0

In the rtmp function, I want to pass the loop iterator i into the getRTMP function to just keep track of the row it's on. When I try to type "getRTMP (0.7, i)" into line 15 and press enter, I get a message box saying "Compile error: Expected: list separator or )" error. My objective is to paste the value from L7 on the row i, within the getRTMP function.

I'd like to be able to add more lines like "getRTMP (0.8, i)", "getRTMP (0.9, i)", etc., but this is stopping me at just the first case.

Is this even possible? I feel like it shouldn't be this difficult and I'm missing something obvious. Maybe the types are off (sorry, slight newbie to VBA here), but I think they check out.

My current code (edited truly unrelated parts out):

Sub rtmp()
Dim i As Integer

' Run accts
For i = 3 To 18
    ' Paste accts to get data
    Sheets("RTMP calcs").Select
    Range("A" & i).Select
    Selection.Copy
    Sheets("Savings Summary").Select
    Range("I1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    
    getRTMP (0.7)
    getRTMP (0.7, i) 'Ideally, this is what the previous line would look like
    
Next i    
End Sub

Sub getRTMP(ByVal CBL As Single, ByVal i As Integer)
    Dim CBL As Single
    Dim i As Integer
    ' Sets the CBL %
    Sheets("Savings Summary").Select
    Range("P6").Select
    Selection.Value = CBL

    ' Copy CBL
    Range("L7").Select
    Selection.Copy
    Sheets("RTMP calcs").Select
    Range("G" & i).Select 'This line and the one below aren't in yet,
    Selection.Paste       'but this is what it would basically look like

End Sub
BigBen
  • 46,229
  • 7
  • 24
  • 40
  • You shoul remove the bracket, i.e `getRTMP 0.7, i` or use Call like `Call getRTMP(0.7, i)` – Storax Feb 11 '22 at 19:14
  • You are once using "i" as a parameter and at the other place declare it as a new var `Sub getRTMP(ByVal CBL As Single, ByVal i As Integer) Dim CBL As Single Dim i As Integer ` – Hangover Sound Sound Feb 11 '22 at 19:15
  • You don't need to (and shouldn't) edit a solution into your question, so I've rolled back your latest edit. – BigBen Feb 11 '22 at 19:33

0 Answers0