Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 12th, 2010, 01: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
 
Old August 12th, 2010, 09:18 PM
Friend of Wrox
 
Join Date: Sep 2005
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)
 
Old August 13th, 2010, 11:03 AM
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





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.