Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Error Msg: 'No Cells were found'

I'm trying to build an array where the start of each
element will be defined by a particular value in
Col 6.

In the following code I receive the above error message
on the line marked ***

For Each ws In Workbooks(SourceWorkbook).Worksheets()
With ws
Shtname = ws.Name
Dim i As Long
Dim varr()
Dim rng As Range, Cell As Range, rng1 As Range
ReDim varr(1 To 1)

If Not (UCase(.Name) = "MASTER" Or UCase(.Name) _
= "COVER" Or UCase(.Name) = "CONTENTS" Or _
UCase(.Name) = "SUMMARY") Then
*** Set rng = Columns(6).SpecialCells(xlConstants, xlTextValues)
For Each Cell In rng
If Cell.Value = "£" Then
If IsEmpty(varr(1)) Then
Set varr(1) = Cell
Else
ReDim Preserve varr(1 To UBound(varr) + 1)
Set varr(UBound(varr)) = Cell
End If
End If
Next
etc

As far as I can see with the test workbook, there are instances of
'£' in Col 6 in every worksheet. Why does the code appear to fail to
find '£', please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.500 / Virus Database: 298 - Release Date: 10/07/2003


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Error Msg: 'No Cells were found'

Stuart

why do you believe the routine is not finding "£" signs ? What do you next
that doesn't work as you expect it to ?

The following extract from your code finds "£" signs in column 6 ... but
each entry in the array just contains a "£" sign. Is that what you expect ?

Dim i As Long
Dim varr()
Dim rng As Range, Cell As Range, rng1 As Range
ReDim varr(1 To 1)
Set rng = Columns(6).SpecialCells(xlConstants, xlTextValues)
For Each Cell In rng
If Cell.Value = "£" Then
If IsEmpty(varr(1)) Then
Set varr(1) = Cell
Else
ReDim Preserve varr(1 To UBound(varr) + 1)
Set varr(UBound(varr)) = Cell
End If
End If
Next

In my test I have four cells with values, only three of them "£" signs. I
ended up with an array of three elements, each containing a "£" sign.
Doesn't seem that useful an exercise but maybe I've just taken it out of
context ? If the cell contains anything besides the "£" sign it will be
ignored, for example, "£x"

Maybe you need: If Cell.Value Like "£*" Then

Another thought: if the contents of the cell is interpreted as a monetary
value then I don't think SpecialCells(xlConstants, xlTextValues) picks it
up.

As you are running this across all the worksheets, how do you plan to use
the information gathered ?

I think you need to step through your code to see what cells are included in
rng and how they are handled.

Regards

Trevor


"Stuart" wrote in message
...
I'm trying to build an array where the start of each
element will be defined by a particular value in
Col 6.

In the following code I receive the above error message
on the line marked ***

For Each ws In Workbooks(SourceWorkbook).Worksheets()
With ws
Shtname = ws.Name
Dim i As Long
Dim varr()
Dim rng As Range, Cell As Range, rng1 As Range
ReDim varr(1 To 1)

If Not (UCase(.Name) = "MASTER" Or UCase(.Name) _
= "COVER" Or UCase(.Name) = "CONTENTS" Or _
UCase(.Name) = "SUMMARY") Then
*** Set rng = Columns(6).SpecialCells(xlConstants, xlTextValues)
For Each Cell In rng
If Cell.Value = "£" Then
If IsEmpty(varr(1)) Then
Set varr(1) = Cell
Else
ReDim Preserve varr(1 To UBound(varr) + 1)
Set varr(UBound(varr)) = Cell
End If
End If
Next
etc

As far as I can see with the test workbook, there are instances of
'£' in Col 6 in every worksheet. Why does the code appear to fail to
find '£', please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.500 / Virus Database: 298 - Release Date: 10/07/2003




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Error Msg: 'No Cells were found'

Thanks for the reply.

I've taken the problem a little further, at least as far as
my limited knowledge allows.

My latest post explains what I've been using the array
for.......ie to collect the 'page' start instances in col(6).

Regards and thanks.

"Trevor Shuttleworth" wrote in message
...
Stuart

why do you believe the routine is not finding "£" signs ? What do you

next
that doesn't work as you expect it to ?

The following extract from your code finds "£" signs in column 6 ... but
each entry in the array just contains a "£" sign. Is that what you expect

?

Dim i As Long
Dim varr()
Dim rng As Range, Cell As Range, rng1 As Range
ReDim varr(1 To 1)
Set rng = Columns(6).SpecialCells(xlConstants, xlTextValues)
For Each Cell In rng
If Cell.Value = "£" Then
If IsEmpty(varr(1)) Then
Set varr(1) = Cell
Else
ReDim Preserve varr(1 To UBound(varr) + 1)
Set varr(UBound(varr)) = Cell
End If
End If
Next

In my test I have four cells with values, only three of them "£" signs. I
ended up with an array of three elements, each containing a "£" sign.
Doesn't seem that useful an exercise but maybe I've just taken it out of
context ? If the cell contains anything besides the "£" sign it will be
ignored, for example, "£x"

Maybe you need: If Cell.Value Like "£*" Then

Another thought: if the contents of the cell is interpreted as a monetary
value then I don't think SpecialCells(xlConstants, xlTextValues) picks it
up.

As you are running this across all the worksheets, how do you plan to use
the information gathered ?

I think you need to step through your code to see what cells are included

in
rng and how they are handled.

Regards

Trevor


"Stuart" wrote in message
...
I'm trying to build an array where the start of each
element will be defined by a particular value in
Col 6.

In the following code I receive the above error message
on the line marked ***

For Each ws In Workbooks(SourceWorkbook).Worksheets()
With ws
Shtname = ws.Name
Dim i As Long
Dim varr()
Dim rng As Range, Cell As Range, rng1 As Range
ReDim varr(1 To 1)

If Not (UCase(.Name) = "MASTER" Or UCase(.Name) _
= "COVER" Or UCase(.Name) = "CONTENTS" Or _
UCase(.Name) = "SUMMARY") Then
*** Set rng = Columns(6).SpecialCells(xlConstants, xlTextValues)
For Each Cell In rng
If Cell.Value = "£" Then
If IsEmpty(varr(1)) Then
Set varr(1) = Cell
Else
ReDim Preserve varr(1 To UBound(varr) + 1)
Set varr(UBound(varr)) = Cell
End If
End If
Next
etc

As far as I can see with the test workbook, there are instances of
'£' in Col 6 in every worksheet. Why does the code appear to fail to
find '£', please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.500 / Virus Database: 298 - Release Date: 10/07/2003






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.500 / Virus Database: 298 - Release Date: 10/07/2003


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Program.xls cannot be found error R Weeden Excel Discussion (Misc queries) 13 May 2nd 23 03:43 AM
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
error "module not found" Amit Excel Discussion (Misc queries) 1 May 13th 05 01:24 PM
The search key was not found error Nydia New Users to Excel 0 April 27th 05 03:09 PM
Error; chart wasn't found Metin Excel Discussion (Misc queries) 1 February 25th 05 01:29 AM


All times are GMT +1. The time now is 04:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"