ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range Issue (https://www.excelbanter.com/excel-programming/382639-range-issue.html)

Arturo

Range Issue
 

HeadingsToSync = Array("111", "222", "333", "ABC", "ABC %Total", "123ABC /
321CBA")
For y = LBound(HeadingsToSync) To UBound(HeadingsToSync)

Set rngFound = Cells.Find(What:=y, _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=True, _
SearchFormat:=False)

If rngFound Is Nothing Then

Else
rngFound.Select

Next y
================================
Manually searching for 111 works fine.
Not sure why the above approach when stepping through rngFound.Select does
not get me to that cell with a value of 111€¦

Appreciatively,
Arturo

JE McGimpsey

Range Issue
 
Probably because the value in your worksheet is a number (111) while the
value in your array is Text.

In article ,
Arturo wrote:

HeadingsToSync = Array("111", "222", "333", "ABC", "ABC %Total", "123ABC /
321CBA")
For y = LBound(HeadingsToSync) To UBound(HeadingsToSync)

Set rngFound = Cells.Find(What:=y, _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=True, _
SearchFormat:=False)

If rngFound Is Nothing Then

Else
rngFound.Select

Next y
================================
Manually searching for 111 works fine.
Not sure why the above approach when stepping through rngFound.Select does
not get me to that cell with a value of 111€¦

Appreciatively,
Arturo


Arturo

Range Issue
 
Any suggestions.


"JE McGimpsey" wrote:

Probably because the value in your worksheet is a number (111) while the
value in your array is Text.

In article ,
Arturo wrote:

HeadingsToSync = Array("111", "222", "333", "ABC", "ABC %Total", "123ABC /
321CBA")
For y = LBound(HeadingsToSync) To UBound(HeadingsToSync)

Set rngFound = Cells.Find(What:=y, _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=True, _
SearchFormat:=False)

If rngFound Is Nothing Then

Else
rngFound.Select

Next y
================================
Manually searching for 111 works fine.
Not sure why the above approach when stepping through rngFound.Select does
not get me to that cell with a value of 111€¦

Appreciatively,
Arturo



Dave Peterson

Range Issue
 
Instead of:
Set rngFound = Cells.Find(What:=y, _
you may want:
Set rngFound = Cells.Find(What:=headingstosync(y), _

Y is still just the index--not the value. (Refer to your earlier post.)


Arturo wrote:

Any suggestions.

"JE McGimpsey" wrote:

Probably because the value in your worksheet is a number (111) while the
value in your array is Text.

In article ,
Arturo wrote:

HeadingsToSync = Array("111", "222", "333", "ABC", "ABC %Total", "123ABC /
321CBA")
For y = LBound(HeadingsToSync) To UBound(HeadingsToSync)

Set rngFound = Cells.Find(What:=y, _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=True, _
SearchFormat:=False)

If rngFound Is Nothing Then

Else
rngFound.Select

Next y
================================
Manually searching for 111 works fine.
Not sure why the above approach when stepping through rngFound.Select does
not get me to that cell with a value of 111€¦

Appreciatively,
Arturo



--

Dave Peterson

Ralph

Range Issue
 
You are searching for the index in the array in this case 0,1,2,3,4,5

try the following:

Dim HeadingsToSync As Variant
Dim y As Integer
Dim rngFound As Range

HeadingsToSync = Array("111", "222", "333", "ABC", "ABC %Total", "123ABC
/321 CBA ")
For y = LBound(HeadingsToSync) To UBound(HeadingsToSync)

Set rngFound = Cells.Find(What:=HeadingsToSync(y), _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=True, _
SearchFormat:=False)

If rngFound Is Nothing Then

Else
rngFound.Select
End If


Next y

"Arturo" wrote:

Any suggestions.


"JE McGimpsey" wrote:

Probably because the value in your worksheet is a number (111) while the
value in your array is Text.

In article ,
Arturo wrote:

HeadingsToSync = Array("111", "222", "333", "ABC", "ABC %Total", "123ABC /
321CBA")
For y = LBound(HeadingsToSync) To UBound(HeadingsToSync)

Set rngFound = Cells.Find(What:=y, _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=True, _
SearchFormat:=False)

If rngFound Is Nothing Then

Else
rngFound.Select

Next y
================================
Manually searching for 111 works fine.
Not sure why the above approach when stepping through rngFound.Select does
not get me to that cell with a value of 111€¦

Appreciatively,
Arturo




All times are GMT +1. The time now is 12:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com