View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Thulasiram[_2_] Thulasiram[_2_] is offline
external usenet poster
 
Posts: 106
Default What is the output of this code (CODE given)

Hello all,

Given below are two cases which is a part (excerpt) of a big bunch of
code. I am not able to interpret certain part of the code. I have given
those, below each case.

case1: (works correctly)

idex = target.value

Set rng1 = sh.Columns(1).Find( _
What:=idex, _
After:=sh.Range("A65536"), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If Not rng1 Is Nothing Then
rng1.Interior.ColorIndex = 3
Set rng2 = rng1.Offset(0, 1).Resize(1, 255) ' ======= what
does this line mean?

I WOULD LIKE TO KNOW THE OUTPUT OF THE PREVIOUS LINE. I.E. WHAT WOULD
BE RNG2

case2: (error in last line)

idex = target.value

Set rng11 = sh.Columns(2).Find( _
What:=idex, _
After:=sh.Range("B65536"), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If Not rng11 Is Nothing Then
rng11.Interior.ColorIndex = 3
' Debug.Print "1a", rng1.Address(0, 0, xlA1, True)
Set rng22 = rng11.Offset(0, 1).Resize(1, 255) '
============== Error '1004' Application '

defined or object defined error

IN THIS CASE, I AM TWEAKING THE CODE IN CASE 1 A LITTLE, BUT I GET AN
ERROR IN THE PREVIOUS LINE..

I think if I understand the last line in case1, I can fix the last line
in case2.
If someone could give the probable/possible reason for the error in
case2, I would deeply appreciate it.

Thanks,
Thulasiram