Doubt in passing parameter to excel !!

ganesha

New Member
Joined
Mar 5, 2012
Messages
7
hello,

i am wariting a vba code where i am calling a function again and again. Is there any way i can avoid writing it again but call in a loop. your suggetsions would be highly appreciated. thanks in advance.

Call InputSubLoop(1, Range("A1"), Range("B1"))

Call InputSubLoop(2, Range("A2"), Range("B2"))

Call InputSubLoop(3, Range("A3"), Range("B3"))

Call InputSubLoop(4, Range("A4"), Range("B4"))


the function InputSubLoop looks like below,

Sub InputSubLoop(no, param1 As Range, param2 As Range)

End sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Perhaps (not tested)

Code:
Dim i as Long
For i = 1 to 4
   Call InputSubLoop(i, Range("A"&i), Range("B"&i))
Next i

Not that there's anything wrong with your code if it works!

Regards
Adam
 
Upvote 0
Welcome to the board..

Try something like

Code:
Dim MyRange As Range, c As Range
 
Set MyRange = Range("A1:A4")
 
For Each c in MyRange
    Call inputSubLoop(c.Row, c, Range("B" & c.Row))
Next c
 
Upvote 0
:) It is working... thanks a lot Mr.James... thanks again for so fast and accurate reply !! good day !!
 
Upvote 0

Forum statistics

Threads
1,215,429
Messages
6,124,840
Members
449,193
Latest member
MikeVol

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