+ Reply to Thread
Results 1 to 10 of 10

Macro to loop between multiple columns and copy the text in one column

  1. #1
    Forum Contributor
    Join Date
    08-12-2013
    Location
    India
    MS-Off Ver
    Office 365
    Posts
    147

    Macro to loop between multiple columns and copy the text in one column

    Hello Guys,

    I need a help in creating a one macro which can resolve my below requirements:

    1. There are 1000 of rows in sheet and we are using a V-lookup in columns no. – G, H, I and J for fetching the status from multiple sheets for unique app id present in Column B.
    2. Generally, between columns no. G, H, I and J; only one column will have the status (could be any text, for ex: approved or conditioned etc.) and other columns will have the “#N/A” (value not available) error.
    3. My requirement is, macro has to look for the status in the columns no. G, H, I and J (ignore if column is containing “#NA”) and if found then copy it and do paste special in Column E (in same row).

    Any help would be appreciated a lot. Please refer the attached sample sheet.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Macro to loop between multiple columns and copy the text in one column

    Hi Manish,
    try it
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    08-12-2013
    Location
    India
    MS-Off Ver
    Office 365
    Posts
    147

    Re: Macro to loop between multiple columns and copy the text in one column

    Hello nilem,

    You are right, column range is from F to I (mistakenly i had wrote G to J).

    But, macro is not working. The "No cell is found" is coming at below line:

    r.Cells(1, 0).Value = r.SpecialCells(xlCellTypeFormulas, 3)

  4. #4
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Macro to loop between multiple columns and copy the text in one column

    Manish, are there formulas in your range F3:I7 or only values?

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

    Re: Macro to loop between multiple columns and copy the text in one column

    Hi Nilem,
    I do not know on the actual data, but on the attached sample, there are no formulas, but values ONLY.

  6. #6
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Macro to loop between multiple columns and copy the text in one column

    Hi AB, I have focused on this:
    Quote Originally Posted by Manish_Gupta View Post
    ... and we are using a V-lookup in columns ...

  7. #7
    Forum Contributor
    Join Date
    08-12-2013
    Location
    India
    MS-Off Ver
    Office 365
    Posts
    147

    Re: Macro to loop between multiple columns and copy the text in one column

    Hi nilem,

    In sample sheet i had removed but in original sheet there will be a vlookup in the cells.

    What we do is we manually insert the vlookup in the F to I columns to fetch the status from multiple workbooks of app id's in column B and then want to run macro who will check for the staus in these columns against column B and update it into column D via ignoring the "#NA" errors.

    Thanks

  8. #8
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Macro to loop between multiple columns and copy the text in one column

    Hi Manish,
    I think the previous code should work correctly, but also try it
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    08-12-2013
    Location
    India
    MS-Off Ver
    Office 365
    Posts
    147

    Re: Macro to loop between multiple columns and copy the text in one column

    Hi nilem,

    Many thanks to you. This Macro is working perfect.

    Only one change if you can do in it is in column G there is a numeric value. Can we add somewhere in a Macro that if there is an numeric value in Column G (only for column G) then it should update the status in column D as an "Filed".

    Thanks,

  10. #10
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Macro to loop between multiple columns and copy the text in one column

    Please Login or Register  to view this content.

+ 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. Replies: 3
    Last Post: 03-27-2013, 03:58 PM
  2. MAcro to - copy, transpose, text to columns, remove column A, combine all columns in 1
    By galvinpaddy in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 02-07-2013, 08:48 AM
  3. [SOLVED] Macro to copy text from multiple defined columns to a new sheet
    By spikedog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-27-2012, 11:56 AM
  4. Replies: 5
    Last Post: 06-20-2012, 05:19 AM
  5. Copy multiple columns in a loop
    By rhudgins in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-08-2010, 07:45 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