+ Reply to Thread
Results 1 to 6 of 6

Why aren't values being transcribed?

  1. #1
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Why aren't values being transcribed?

    I'm comparing two worksheets within a workbook. WkSht1 and WkSht2 are strings entered through inputboxes for the worksheet names to be compared (in the example List1 and List 2).
    The macro is assigning the proper range to WkSht1Range and entering those addresses in Col A of "Differences Sheet" but it is entering all addresses in the range and not recording any values in Columns B and C. Here's the code of interest
    Please Login or Register  to view this content.
    So I have two initial issues.
    1. Why all addresses and not just the ones where the two sheet values do not agree?
    2. Why isn't it transcribing the sheet values?
    Thanks in advance.
    Workbook attached.
    Attached Files Attached Files
    Last edited by ChemistB; 07-26-2011 at 10:29 AM. Reason: Updated file with expected results
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Why aren't values being transcribed?

    you forgot a lot of dots:
    But it's not clear to me what you want to compare.
    I think you should also dive into how to 'address' sheets, columns , ranges in Excel

    Please Login or Register  to view this content.
    But maybe a oneliner suffices ( cfr. the attachment):

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by snb; 07-25-2011 at 04:12 PM.



  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Why aren't values being transcribed?

    Hi snb. No, that's still not doing it (even when I remove the quotes from around WkSht1 and 2 since they are string variables). I'm going to modify my attached spreadsheet above to show what I would expect as results.

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Why aren't values being transcribed?

    I amended my previous code and added an attachment.
    See if this is what you meant.

  5. #5
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,255

    Re: Why aren't values being transcribed?

    Hi Chemist,

    I know you'd like to get to the bottom of this yourself, so I'll give you a starting point.

    (1) Add Option Explicit to the top of your code module.
    (2) Comment out the On Error Resume Next.

    Now try to debug it. Step through the code pressing F8 (once you've managed to compile it by declaring all of your variables) and, once you've sorted out the naming of the new sheet, pay particular attention to the error thrown on this line:
    Please Login or Register  to view this content.
    At the moment, your On Error Resume Next (which you will now have commented out) is masking this error.
    Hope that helps,

    Colin

    RAD Excel Blog

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Why aren't values being transcribed?

    Thanks Colin, that found my incorrect variable near the end of the code and alerts me that the line you pointed out is invalid. Then whereever I had Cell as a range object, I replaced it with Range(cell.Address) (not sure why "cell" doesn't work on it's own though). Now it's working like I want it to. Thanks to both you and snb.

    Okay, going to start a new thread for my next question. "In this code, I'm assuming that the used range for wksht1 and wksht2 are the same size (theoretically they should be). I want to know how to check if they are.

+ 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