Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Type Mismatch on some PCs

I understand perfectly what your suggestion is doing and when I said it
doesn't work, I meant it doesn't give me the required result. I agree that
it is difficult without seeing a file. I have followed gocush advice and
posted a dummy file on Woodys Lounch (post number 443817) if you wish to have
a look. The main point here is the code, as written in the file works on 98%
of PCs, just not on all, and these are the users who get Type Mismatch errors.

"Tom Ogilvy" wrote:

My Suggestion only acts on cells that are True and avoids a type mismatch
error caused by the value in the cell. How the cell in question receives
its value is outside the context of the code, but arbitrarily changing it
certainly isn't something I would recommend. The later post by delboy
implies that these cells reflect choices made by the user, so this would be
even more reason not to arbitrarily change them.

Since delboy says he can't get the solutions to work I can only conclude he
doesn't understand the suggestions (or hasn't implemented them as intended),
he has not provided essential details concerning the error, or the cause of
the error extends beyond the information presented.

--
Regards,
Tom Ogilvy


"gocush" /delete wrote in message
...
What if ithe cell color index = say, 35 and the cell value = "Hello" or

10
or blank
Then the 1st half of the code doesn't change it to TRUE or "True"

I think that if this could be the case then either the first section of

code
must change the cell to True or "True" Or, in the 2nd half of the code

make
the condition the same as in the 1st half:

Range("C12:C514").Select
For Each cell In Selection
If Not cell.Interior.ColorIndex = 45 Then '<=== Use Not or change =

to
<
cell.EntireRow.Hidden = False
Else
cell.EntireRow.Hidden = True
End If
Next cell

"Tom Ogilvy" wrote:

If you don't want to change the value in the cell you could do

Range("C12:C514").Select
For Each cell In Selection
If cell.Interior.ColorIndex = 45 Then
cell.Value = False
End If
Next cell


Range("C12:C514").Select
For Each cell In Selection
If cell.Text = "True" Then ' <== change
cell.EntireRow.Hidden = False
Else
cell.EntireRow.Hidden = True
End If
Next cell

--
Regards,
Tom Ogilvy

"gocush" /delete wrote in message
...
Try adding two lines to the first section of code:

Range("C12:C514").Select
For Each cell In Selection
If cell.Interior.ColorIndex = 45 Then
cell.Value = False
Else
cell.Value = True
End If
Next cell


"Delboy" wrote:

I have an Excel workbook which has some code on one of the sheets.

All
this
does is hide or unhide rows depending on whether there word true is
found in
column C (in the row thath will be hidden or revealed). The

true/false
is
created from a tick box which the user selects, there are a number

of
them.
So far, its all straight forward and this works on 98% of peoples

PCs,
but
some people get a Run time error, type mismatch when they click a

tick
box.
They are all running the same system Win XP and Excel 2002. Has

anybody
got
any ideas on how to fix this? The code is as follows:

Range("C12:C514").Select
For Each cell In Selection
If cell.Interior.ColorIndex = 45 Then
cell.Value = False
End If
Next cell


Range("C12:C514").Select
For Each cell In Selection
If cell = True Then
cell.EntireRow.Hidden = False
Else
cell.EntireRow.Hidden = True
End If
Next cell








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
Type mismatch? John Wirt[_9_] Excel Programming 6 December 11th 04 09:37 PM
Type Mismatch Jack Schitt Excel Programming 2 September 3rd 04 11:55 AM
Type Mismatch Edgar[_3_] Excel Programming 4 February 13th 04 03:55 PM
Type Mismatch Phil Hageman[_3_] Excel Programming 2 January 9th 04 06:11 PM


All times are GMT +1. The time now is 05:06 PM.

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"