+ Reply to Thread
Results 1 to 8 of 8

Run-time error '13' with drop-down list

  1. #1
    Registered User
    Join Date
    04-17-2013
    Location
    Montréal
    MS-Off Ver
    Excel 2010
    Posts
    7

    Run-time error '13' with drop-down list

    Hello,

    I succeed to have if A1 not empty then B1 = A1 but if at the same time B1 = not empty, then do not replace B1 by A1 :

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Range("A1") And Range("B1") = "" Then
    Range("B1") = [A1]
    End If
    End Sub

    The problem is that it doesn't work when cells A1 and B1 include drop-down lists with letter and number : D4, B3, F2... (but it works if only numbers : 22, 56...)

    I have : "Run-time error '13' type mismatch"

    Is-it possible to fix it ?

    Thanks a lot for the help
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Run-time error '13' with drop-down list

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-17-2013
    Location
    Montréal
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Run-time error '13' with drop-down list

    Thank you. I got no more the error but the code doesn't work. Nothing happens in B1 when A1 is not empty.
    Did I miss something ?

  4. #4
    Registered User
    Join Date
    04-17-2013
    Location
    Montréal
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Run-time error '13' with drop-down list

    Hello,

    nobody to help ?

    I really need to fix this error.

    Thank you all

  5. #5
    Forum Contributor
    Join Date
    01-30-2013
    Location
    Wales
    MS-Off Ver
    Excel 2013
    Posts
    231

    Re: Run-time error '13' with drop-down list

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Run-time error '13' with drop-down list

    Chris,
    What is the triggering target(Column, Row, cell address)?
    What need to be changed in order for the code to run?
    For.eg
    Please Login or Register  to view this content.
    Means you triggering column is 2, or B.

    OR

    Please Login or Register  to view this content.
    trigger
    Means you triggering column is E
    I think there are many parameters missing from your code

  7. #7
    Forum Contributor
    Join Date
    01-30-2013
    Location
    Wales
    MS-Off Ver
    Excel 2013
    Posts
    231

    Re: Run-time error '13' with drop-down list

    Thanks AB33

    I think this is down to my incomplete understanding of the required parameters. I've been using spreadsheets for a few years but have only recently become aware things like Worksheet_selectionChange. As with most things I've found in excel it just opens up so many aspects of excel that I wasn't aware of.

    As I understand the original post this should only work when A1 or B1 is changed, so would that be
    Please Login or Register  to view this content.
    When I tried my incomplete version it worked, so does limiting the target make it more elegant and faster, or is it just a nicety?

    Still learning.

    Chris

  8. #8
    Registered User
    Join Date
    04-17-2013
    Location
    Montréal
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Run-time error '13' with drop-down list

    Many thanks guys. With your solution Chris it works perfectly. I suppose that with AB33 proposal, I should be able to extend the solution to more than one cell wich would be very cool.

    I mean if A1 not empty then B1 and B2... = A1 but if at the same time B1 = not empty or B2 = not empty..., then do not replace B1 or B2 or... by A1.

    But I have more to learn than Chris and I'm not able to use your proposal to extend Chris's solution to more than one cell.

    For know, I just repeat Chris's solution with the other cell B2. Not very elegant but it works. For sure, not the good solution if there are more cells to do, B1 to B50 for example...

    Anyway, it works and you make a happy guy %)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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