+ Reply to Thread
Results 1 to 2 of 2

Datatype Conversion in For Loop P

  1. #1
    Registered User
    Join Date
    01-17-2013
    Location
    Austin, TX
    MS-Off Ver
    Excel 2007
    Posts
    84

    Datatype Conversion in For Loop P

    I'm trying to go through a column of numbers in a for loop and convert "N/A" to "IN lol NOT IN xkcd", however, I'm running into a conversion error run time 13 when it does the comparison of \
    xkcd.Cells(i, 3).Value = "#N/A.
    I'm at a lost at how to debug it, I've tried CStr. Below is the code I'm using and the error message.


    ' Dim i as Long
    ' Dim LrowPart2 As Long
    ' Dim xkcd As WorkSheet
    ' For i = 1 To lrowPart2
    ' If xkcd.Cells(i, 3).Value = "#N/A" Then
    ' xkcd.Cells(i, 3).Interior.Color = RGB(255, 255, 0)
    ' xkcd.Cells(i, 3).Value = "IN lol NOT IN xkcd"
    ' End If
    ' Next i

    https://msdn.microsoft.com/en-us/lib...(v=vs.60).aspx

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Datatype Conversion in For Loop P

    Hi,

    You can't directly compare an error value to a string. You can use
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    the latter should perform better though if you do not have too much data the former will be fine.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA - Datatype to be used to Store Time value
    By Vinod Krishna.C in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-11-2014, 09:25 AM
  2. datatype confusion
    By brianr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-06-2010, 02:58 PM
  3. Declare datatype
    By Renu Rathor in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-05-2008, 11:21 AM
  4. DataType
    By matrixknow in forum Excel General
    Replies: 1
    Last Post: 05-23-2007, 09:23 AM
  5. DDERequest DataType
    By Barang in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-06-2006, 08:11 AM
  6. [SOLVED] determining datatype
    By davegb in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-01-2005, 05:35 PM
  7. DataType Property
    By Access101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-25-2005, 04:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1