+ Reply to Thread
Results 1 to 3 of 3

type mismatch Error when writing data to excel

  1. #1
    Registered User
    Join Date
    11-27-2013
    Location
    Mumbai
    MS-Off Ver
    Excel 2007
    Posts
    35

    type mismatch Error when writing data to excel

    Please Login or Register  to view this content.
    i have above code
    i am writing data to excel files from from application

    when execute below line it doesnot give error
    sheet1.Range("L4").Value = datatable1.Rows.Count

    but on executing
    sheet1.Range("B4").Value = CStr(txtname.Text)

    it gives type mismatch error

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,701

    Re: type mismatch Error when writing data to excel

    Extracted from Ms-office VBA help....

    Boolean
    A string containing True or False

    Date
    A string containing a date in the short date format of your system

    Null
    A run-time error

    Empty
    A zero-length string ("")

    Error
    A string containing the word Error followed by the error number

    Other
    numeric A string containing the number


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Guru Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,249

    Re: type mismatch Error when writing data to excel

    Is txtname.text a value, or a string? the CStr function expects a value.

    You could replace that line with:
    Please Login or Register  to view this content.
    Which would then cope with being passed either a value or a string.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

+ 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. Error 13 Type Mismatch in excel VB
    By sid_excelforum in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-27-2013, 06:14 PM
  2. Type Mismatch Error on Large Data Sets
    By erock24 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-04-2010, 04:40 PM
  3. [SOLVED] Type mismatch error in Excel
    By r_fordjr@msn.com in forum Excel General
    Replies: 1
    Last Post: 04-28-2006, 12:45 PM
  4. type mismatch error-copies data from one sheet to another
    By Marcotte A in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2005, 10:25 PM
  5. [SOLVED] Type Mismatch Error when getting data from another workbook
    By Tony Zappal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-12-2005, 07:06 PM

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