Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 12th, 2010, 02:10 PM
Registered User
 
Join Date: Aug 2010
Posts: 4
Thanks: 0
Thanked 3 Times in 2 Posts
Angry Type mismatch error Excel (VBA) linked to SharePoint List

I am writing VBA in Excel 2003 sheet that is linked to SharePoint 2007 List. What I am trying to achieve is to set five value options to the cells in certain range and cell color should be changed depending on the value selected every time a user changes a value of the cell. Since Conditional formatting function of Excel 2003 only supports three conditions, I wrote the following code to perform the conditional formatting, and it worked fine when I changed cell value in Excel itself. However, it gives me "Type mismatch" error when I try to update the Excel cell values by Synchronizing with the linked SharePoint. Any idea to make it work?

Private Sub Worksheet_Change(ByVal Target As Range)

Dim icolor As Integer

If Not Intersect(Target, Range("W1:CS200")) Is Nothing Then

Select Case Target

Case "Not Feasible/Applicable (Black)"

icolor = 1

Case "No Plan Available (Red)"

icolor = 3

Case "Have a plan (Yellow)"

icolor = 6

Case "Need Help (Pink)"

icolor = 7

Case "Implemented (Green)"

icolor = 50

Case Else

'Do nothing

End Select

Target.Interior.ColorIndex = icolor

End If

End Sub
Reply With Quote
  #2 (permalink)  
Old August 12th, 2010, 10:18 PM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Can you specify the line where you are getting this error

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
Reply With Quote
  #3 (permalink)  
Old August 13th, 2010, 12:03 PM
Registered User
 
Join Date: Aug 2010
Posts: 4
Thanks: 0
Thanked 3 Times in 2 Posts
Smile Type mismatch error Excel (VBA) linked to SharePoint List

Thank you for your prompt response. The following were the steps I took for testing.

(1) I inserted Debug.Print in my code for debugging (see below).
(2) I updated one cell value to "Have a plan (Yellow)" in the linked SharePoint list.
(3) I clicked "Synchronized icon" in the Excel sheet.
(4) The run time error occurred and debug pointer is pointing the line -> Case "Not Feasible/Applicable (Black)". I assume that this is the first line of "Select Case" section". Immediate window shows: "Have a plan (Yellow)".

I appreciate if you could help me on this error.

Code:
 

Private Sub Worksheet_Change(ByVal Target As Range)

Dim icolor As Integer

If Not Intersect(Target, Range("W1:CS200")) Is Nothing Then

 Select Case Target

  Case "Not Feasible/Applicable (Black)"

     icolor = 1
     Debug.Print "Not Feasible/Applicable (Black)"
     
  Case "No Plan Available (Red)"

     icolor = 3
     Debug.Print "No Plan Available (Red)"
     
  Case "Have a plan (Yellow)"

     icolor = 6
     Debug.Print "Have a plan (Yellow)"
     
  Case "Need Help (Pink)"

     icolor = 7
     Debug.Print "Need Help (Pink)"
  
  Case "Implemented (Green)"

     icolor = 50
     Debug.Print "Implemented (Green)"
  
  Case Else

   'Do nothing

End Select

  Target.Interior.ColorIndex = icolor

End If

End Sub
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error-0x800A000D-Type mismatch kishy449 Classic ASP Basics 0 July 23rd, 2007 05:48 AM
Type Mismatch error Sheraz Khan Classic ASP Basics 0 May 16th, 2007 09:12 AM
Data Type mismatch error clueless_may Access VBA 1 May 5th, 2004 10:16 AM
Data Type Mismatch error transcona Classic ASP Databases 4 June 25th, 2003 08:23 PM



All times are GMT -4. The time now is 12:39 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.