+ Reply to Thread
Results 1 to 10 of 10

Macro to copy rows of data in a table which contains a string and change cell value

  1. #1
    Registered User
    Join Date
    08-29-2011
    Location
    NZ
    MS-Off Ver
    Excel 2007
    Posts
    6

    Macro to copy rows of data in a table which contains a string and change cell value

    Hi,

    Please help me with a macro which will copy the rows of data in a table which contains a specific string.

    Also, I'd like to substitute the first cell in the row with the value of the column/s below it from the input table. These are tstrings enclosed in between ( ).

    I've attached sample table for reference. Input table is found in Sheet1, desired output table in Sheet2.


    Thanks so much for your time.

    Regards
    Teresadg
    Attached Files Attached Files

  2. #2
    Forum Contributor Obsessed's Avatar
    Join Date
    05-22-2013
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 365
    Posts
    215

    Re: Macro to copy rows of data in a table which contains a string and change cell value

    Is there a reason your table on sheet 2 omits C160, C161, C162, C163, and separately, R440? Would those theoretically be copied over as well?

  3. #3
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Macro to copy rows of data in a table which contains a string and change cell value

    Maybe :

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    08-29-2011
    Location
    NZ
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Macro to copy rows of data in a table which contains a string and change cell value

    Hi,

    Only the rows where the first cell is BBB and the cells below it, enclosed in between ( ) are significant.

    Cheers.

  5. #5
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Macro to copy rows of data in a table which contains a string and change cell value

    Have you tried to run my macro ?
    The result is on Sheet3

  6. #6
    Registered User
    Join Date
    08-29-2011
    Location
    NZ
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Macro to copy rows of data in a table which contains a string and change cell value

    Hi karedog,

    Thanks for taking time to analyze my problem. I've tried to run this but nothing is showing after the InputBox prompt.

  7. #7
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Macro to copy rows of data in a table which contains a string and change cell value

    That is strange, could you try this :
    Download and open my attachment, then run the macro.
    When the inputbox appeared, enter BBB (all in uppercase).
    Is nothing happened ?
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    08-29-2011
    Location
    NZ
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Macro to copy rows of data in a table which contains a string and change cell value

    Wow!
    Sorry, I imported the code to my current database, which is slightly different from the table I've sent earlier.
    Your code works perfectly, though I should like to remove the rows which doesn't have BBB string on the first row (that will be the 4th and 5th row on Sheet 3 of EF1111351.xls‎ when macro is run.)

    Thanks for your quick reply!

  9. #9
    Registered User
    Join Date
    08-29-2011
    Location
    NZ
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Macro to copy rows of data in a table which contains a string and change cell value

    Hi Karedog,

    I see what happened. The input table was slightly altered. Your code's perfect.
    Thanks again for your assistance.

    Regards
    Teresadg

  10. #10
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Macro to copy rows of data in a table which contains a string and change cell value

    You are welcome, and thanks for the reputation points.


    Regards

+ 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. macro to copy table from sheet1 to sheet2 (# of rows in table may vary everytime)
    By arkharova.s in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-18-2014, 03:18 AM
  2. [SOLVED] Macro to match cell value to worksheet name and copy all rows and row data
    By jamesmcgallan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-28-2013, 09:21 AM
  3. [SOLVED] VBA for searching string in a column and copy rows depending on string in adjacent cell
    By xprakash in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-20-2013, 05:58 AM
  4. Replies: 1
    Last Post: 05-30-2013, 06:29 PM
  5. Replies: 2
    Last Post: 01-02-2013, 08:35 AM
  6. [SOLVED] Macro to copy data from tables with unspecified rows on multiple sheets into one table
    By sara ghaith in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-11-2012, 08:31 AM
  7. macro that will and copy rows only if data is in a cell
    By Traymond in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-20-2009, 12:50 PM
  8. Change data to appear in rows instead of columns (reverse a table.
    By Motheroftwoboys in forum Excel General
    Replies: 2
    Last Post: 03-04-2005, 12:06 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