Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is the output of this code (CODE given)
Set rng22 = rng11.Offset(0, 1).Resize(1, 255)
should be Set rng22 = rng11.Offset(0, 1).Resize(1, 254) rng11 is in column B rng11.offset(0,1) is in column C so 256 column -2 = 254 in the first case, since rng1 is in column B, it can be 255 cells wide. -- Regards, Tom Ogilvy "Thulasiram" wrote in message ps.com... 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is the output of this code (CODE given)
Thanks Tom
Tom Ogilvy wrote: Set rng22 = rng11.Offset(0, 1).Resize(1, 255) should be Set rng22 = rng11.Offset(0, 1).Resize(1, 254) rng11 is in column B rng11.offset(0,1) is in column C so 256 column -2 = 254 in the first case, since rng1 is in column B, it can be 255 cells wide. -- Regards, Tom Ogilvy "Thulasiram" wrote in message ps.com... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. | Excel Programming | |||
Excel code convert to Access code - Concat & eliminate duplicates | Excel Programming | |||
Code runs without error but doesn't print output | Excel Programming | |||
conditional format for vb code on pivot output | Excel Programming |