+ Reply to Thread
Results 1 to 5 of 5

convert a single-celll range to a cell

  1. #1
    Registered User
    Join Date
    10-10-2003
    Posts
    31

    convert a single-celll range to a cell

    The code below generates a type mismatch error as shown. I think it's because 'Target' is a single-cell range, not a cell proper, so 'Target.Value' fails but I don't know how to convert the range to a cell. Help appreciated.

    Please Login or Register  to view this content.
    Thanks - Jim

    Moderators Note: Please follow Forum Rule #3 and use code tags. Added this time, but please use them in the future…Thanks.
    Last edited by jeffreybrown; 12-28-2012 at 03:35 PM.

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: convert a single-celll range to a cell

    Hi Jim,

    The usage of Target.Value is correct in this context. Perhaps the compare against "" (which implies it is a string) is causing the problem?

    You could try

    Please Login or Register  to view this content.
    i.e. LenB is the fastest way to check if a variable is empty
    If you like my contribution click the star icon!

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

    Re: convert a single-celll range to a cell

    The Target.Value is looking for the Range("InputRange")) . What is in it? It looks like a named range. The code will trigger if the target and named range intersect

    Please Login or Register  to view this content.

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

    Re: convert a single-celll range to a cell

    The If statement will only work if Target is one cell and doesn't have an error.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    10-10-2003
    Posts
    31

    Re: convert a single-celll range to a cell

    Thanks all for the quick help. Olaf, I couldn't your solution to work (continued to get mismatch errors); AB33, I didn't try your solution because Norie's solution (which I saw at the same time) was more desirable with respect to error catching and since it worked perfectly I never looked back. Again, thanks all. - Jim (Moderator, sorry about the lack of code tags.)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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