![]() |
procedure/function calling
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 |
procedure/function calling
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 |
All times are GMT +1. The time now is 02:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com