Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi
i am repeatedly using some stmts in the if like If (StrComp(s,a) = 0 Then Range("a" & j).Value = Sheets("sheet2").Range("a" & z).Value Range("b" & j).Value = Sheets("sheet2").Range("h" & z).Value end if If (StrComp(s,b)= 0 Then Range("a" & j).Value = Sheets("sheet2").Range("a" & z).Value Range("b" & j).Value = Sheets("sheet2").Range("h" & z).Value end if here, i m often using the stmts(in red) often . so can somebody help me how to use the procedures for (reusablitiy) i want to pass the values j and z as arguments to the called procedure |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Raja,
One way: Sub Tester04() Dim j As Long, z As Long Dim s As String, a As String, b As String j = 1: z = 10 s = "TEST": a = "test": b = "TEST" If StrComp(s, a) = 0 Then DoIt j, z j = 2: z = 11 If StrComp(s, b) = 0 Then DoIt j, z End Sub Sub DoIt(jCtr As Long, zCtr As Long) Range("a" & jCtr).Value = Sheets("sheet2").Range("a" & zCtr).Value Range("b" & jCtr).Value = Sheets("sheet2").Range("h" & zCtr).Value End Sub --- Regards, Norman "raja" wrote in message ... hi i am repeatedly using some stmts in the if like If (StrComp(s,a) = 0 Then Range("a" & j).Value = Sheets("sheet2").Range("a" & z).Value Range("b" & j).Value = Sheets("sheet2").Range("h" & z).Value end if If (StrComp(s,b)= 0 Then Range("a" & j).Value = Sheets("sheet2").Range("a" & z).Value Range("b" & j).Value = Sheets("sheet2").Range("h" & z).Value end if here, i m often using the stmts(in red) often . so can somebody help me how to use the procedures for (reusablitiy) i want to pass the values j and z as arguments to the called procedure |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Calling sub procedure | Excel Programming | |||
Calling a procedure in a procedure | Excel Programming | |||
Calling a procedure in a procedure | Excel Programming | |||
Calling a procedure in a procedure | Excel Programming | |||
Calling a Custom Function within a Procedure | Excel Programming |