+ Reply to Thread
Results 1 to 9 of 9

Type mismatch error obtaining value from a cell

  1. #1
    Registered User
    Join Date
    01-10-2011
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    32

    Type mismatch error obtaining value from a cell

    Hi there,

    This is probably quite simple, but I haven't found the answer on the forum or elsewhere... please help

    Please Login or Register  to view this content.
    So the idea is that it is going through a set of data one row at a time (using TableRow), and the first task is to extract the ProjectNumber from column d of the row.

    The final line of my code (ProjectNumber = etc) gives me a type mismatch error when I run it.
    The same result occurs with:

    Please Login or Register  to view this content.
    On the other hand, if I do this:

    Please Login or Register  to view this content.
    I get this error instead:
    Object variable or With block variable not set

    ...which makes no sense to me as ProjectNumber is not an object (unless Range is an object of course, but in that case surely I have set it?)

    Confused!!

    Any help appreciated... thanks

    ssu95bm
    Last edited by ssu95bm; 03-09-2015 at 09:58 AM. Reason: SOLVED

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Type mismatch error obtaining value from a cell

    Most probably
    Workbooks(BacklogWorkbook).Sheets("Backlog Data").Range("d" & TableRow)
    is not a Long type data.

    This is all that I can say from your code.

  3. #3
    Registered User
    Join Date
    01-10-2011
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    32

    Re: Type mismatch error obtaining value from a cell

    Sorry, Is should have said what the cell contains... it is a 5 digit number, for example 20752. Right clicking on the cell shows it has a format of "general".

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Type mismatch error obtaining value from a cell

    That's strange.

    Can you upload a workbook with just that data?

  5. #5
    Registered User
    Join Date
    01-10-2011
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    32

    Re: Type mismatch error obtaining value from a cell

    Hi there,

    I have anonymized the data (and reduced it to 2 rows of data) and attached the file.

    The mismatch occurs on line 111 of the code. Note that the code is divided into a number of numbered sections, line 111 is section 7.

    Thanks!
    ssu95bm
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Type mismatch error obtaining value from a cell

    OK

    You have formulas in col.A so it is not Empty.
    change to
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-10-2011
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    32

    Re: Type mismatch error obtaining value from a cell

    Hi there,

    I have amended the code as suggested. Now however I get a type mismatch on the do while row...?

    ssu95bm

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Type mismatch error obtaining value from a cell

    It's not possible to test your code as there's no worksheet named 'Stored Data' in the workbook and there's a request to choose a CSV file to open.

    PS If you want to refer to the workbook the code is in you can use ThisWorkbook.
    If posting code please use code tags, see here.

  9. #9
    Registered User
    Join Date
    01-10-2011
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    32

    Re: Type mismatch error obtaining value from a cell

    With a colleague as the second pair of eyes, I think I have found it. An earlier part of the macro deleted some rows on the sheet "OA data" based on certain values. On "Backlog data" this then broke the references to rows 1, 2, etc and replaced them with #ref. #REF!, of course, is not a long or an integer!

    It looks like I will need to replace all my cell references on the Backlog Data tab with indirect references.

    Thanks.
    ssu95bm.

+ 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. [SOLVED] Run-time error '13': Type mismatch - How to work with Cell.value
    By beutlerm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-30-2014, 01:18 PM
  2. putting an if condition based on text in a cell - runtime error 13: type mismatch
    By rbs123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2013, 04:02 AM
  3. [SOLVED] Display cell reference - runtime error type mismatch
    By Brumbot in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-19-2013, 06:44 AM
  4. Type Mismatch Error when deleting a cell
    By Josiah in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-11-2008, 01:07 PM
  5. [SOLVED] Help: Compile error: type mismatch: array or user defined type expected
    By lvcha.gouqizi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2005, 05: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