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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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,216,081
Messages
6,128,695
Members
449,464
Latest member
againofsoul

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