+ Reply to Thread
Results 1 to 7 of 7

Offset Comment Locations

  1. #1
    Registered User
    Join Date
    02-10-2014
    Location
    United States of America
    MS-Off Ver
    Excel 2013
    Posts
    14

    Offset Comment Locations

    Dear Excel Forum,

    I need some advice cleaning exports from a survey software called MarketSight. The software returns tables as so:

    row x: blank cells possibly with a comment for the value below
    row x + 1: cells with some value

    This repeats over the relevant range (approximately 4000 rows x 20-30 columns). What I would like to do is combine the comments and values.


    One obvious way would be to loop through the range and conditionally PasteSpecial comments to the range below, but I have found this to be very slow. I have also considered simply adding comments rather than copy + paste, but I question how much faster this would be. Any tips?


    Best,
    Doug

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,301

    Re: Offset Comment Locations

    I would use a macro that creates an exactly half-sized range of formulas, below the existing table, with a formula like this - let's say in cells A5001:AZ7500, which will add the comment from the cells in the odd rows to the end of the values in the even rows:

    =TRIM(INDEX($A$1:$AZ$5000,(ROW(A1)-1)*2+2,COLUMN()) & " " & INDEX($A$1:$AZ$5000,(ROW(A1)-1)*2+1,COLUMN()))

    Then copy those cells with formulas, paste values, and delete the original cells. The code with this approach should be much faster:

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    02-10-2014
    Location
    United States of America
    MS-Off Ver
    Excel 2013
    Posts
    14

    Re: Offset Comment Locations

    Dear Bernie,

    Hey, thanks for getting back to me. I am going to look into this formula approach, maybe instead storing it in an array. I am really trying to avoid copy + paste though because of how cumbersome my files can get.

    Would you happen to know of some alternatives? Maybe adding comments without looping (or with precise looping)?


    Best,
    Doug

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,301

    Re: Offset Comment Locations

    Looping is always slower - when you add a formula to an entire range, you take advantage of all the power or Excel. That includes the copying and pasting as values. Upload an example file and I will add my suggested macro to it - have you tried to do it yourself, and run the macro?

  5. #5
    Registered User
    Join Date
    02-10-2014
    Location
    United States of America
    MS-Off Ver
    Excel 2013
    Posts
    14

    Re: Offset Comment Locations

    Dear Bernie,

    So I have attached a data table sample to give you something to test. When I tried your macro, the empty rows were deleted, but there were no added comments and the numbers were inputted as string. Any ideas?


    Best,
    Doug
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,301

    Re: Offset Comment Locations

    By "What I would like to do is combine the comments and values," I thought you meant "combine the comment string with the value in the cell"

    Now that I see the file, this might be how to do it:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-10-2014
    Location
    United States of America
    MS-Off Ver
    Excel 2013
    Posts
    14

    Re: Offset Comment Locations

    Dear Bernie,

    Thanks for all your help. The code above worked and coincidentally had almost the same method as my starting one. This is what I ended up going with:

    Please Login or Register  to view this content.

    and then adding one of the many "delete every nth row" macros. Again, I appreciate your help with this one. I've asked around quite a bit to figure this out. +rep


    Best,
    Doug

+ 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. Add timestamp to comment upon comment creation (Excel 2007)
    By Shadyhaxx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-30-2013, 12:58 PM
  2. Disable Delete Comment, Edit Comment, Show/Hide Comment
    By Shanthan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2013, 06:12 AM
  3. See comment locations in worksheet
    By Lewis Koh in forum Excel General
    Replies: 3
    Last Post: 04-25-2010, 09:40 PM
  4. Replies: 0
    Last Post: 09-04-2008, 01:35 PM
  5. [SOLVED] How can I edit a comment w/o first having to select Show Comment
    By Mary Ann in forum Excel General
    Replies: 1
    Last Post: 08-25-2005, 08:05 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