Get ReturnValue as a numCells to loop subroutines

tiridako

New Member
Joined
Feb 2, 2015
Messages
9
I am looking for a way to pass the ReturnValue of n from function as a numCells to loop a subroutine like so, Call nameSub(n). Is this possible?

I want to perform arithmetic on two variables with assigned value. For example:

Code:
Function mathie(aCur as Integer, preVious as Integer)
    Dim Cat as string, Dog as string, horse as string
    Cat = 1
    Dog = 2
    Horse = 3

      ' And the function would match the string in a cell to the dog/cat/or horse. 
      ' A previous cell might have been Dog, and the next cell in the same 
      ' row is Horse, I would like to also find out how to match named 
      ' variables to text strings. However, I will ask this question another 
      ' time (as briefly mentioned in my last paragraph).

   Dim n as variant
   n = ReturnValue
   aCur = ActiveCell
   preVious = ActiveCell.Offset(0, -1).Select

End Function

Sub loopie(numCells)
   
    For i = 1 To last_col
    .. do something
    Next

End Sub

Sub routine()
    Call loopie(n(Horse - Dog))  
End Sub

I have been trying to figure this out for a few weeks, and reached out to you yesteray as this thread shows, but I've scrapped that for now; I'm focusing on smaller parts for now because I want to learn all parts carefully as I am learning VBA as I go along and would appreciate your help.

Edited for formatting
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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