+ Reply to Thread
Results 1 to 6 of 6

copy rows of data depending on value in 1 column

  1. #1
    Registered User
    Join Date
    09-28-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    copy rows of data depending on value in 1 column

    --------------------------------------------------------------------------------

    Hi all

    Never used macros or VBA before. have searched long and hard but cant get this right.

    I want to copy a row of data dependant on the value in column W. I have 7 sheets that I want to copy from. All the data will be copied to one sheet called 'pilot'.

    The 7 sheets are Named: 'Engalnd & Wales', 'Scotland', 'North', 'south', 'England and Wales (remote', 'Scotland (Remote)', 'other'.

    I want the entire row to copy to the 'pilot' sheet if the value in column W is 'P'. Currently column W either has a value of P or is blank. I can change the blanks to have a value is necessary (e.g. B).

    the data needs to be copied to the next available row in sheet 'pilot'. all sheets have headings in row 1.

    I can't upload the sheet as data is sensitive.

    any help appreciated.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: copy rows of data depending on value in 1 column

    Try this:

    Please Login or Register  to view this content.

    Dom
    Last edited by Domski; 09-28-2010 at 08:00 AM. Reason: Small change to code
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    09-28-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: copy rows of data depending on value in 1 column

    Cheers Dom but that doesn't seem to work. I get an Error 400 message?

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: copy rows of data depending on value in 1 column

    Where do you get that?

    I assumed that each sheet that you want to copy the information from has a contiguous block of data on it with headings in Row 1 and columns starting in Column A across. Is this not the case?

    Dom

  5. #5
    Registered User
    Join Date
    09-28-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: copy rows of data depending on value in 1 column

    yeah that is correct. 9 sheets (tabs) overall. 7 I want to pull the data from, 1 results sheet (pilot) and 1 un-related sheet.

    Several rows of data with headers in row 1.

    I want it to copy the entire row where a 'P' is present in column W (the last column).

    Maybe I'm putting the formula in the wrong place. I open the workbook, go to tools, macros the open VBA. Do I copy the formula into the sheet 1 window or all of the sheets? Or do I just copy the formula into the 'this workbook' window?

    The error appeared when I tried to run the macro. It was copied into the 'this workbook' window.

    cheers

  6. #6
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: copy rows of data depending on value in 1 column

    The code should really sit within a module. You need to add these yourself by right clicking on the project in the explorer and select Insert...module.

    You will need to tell the code to exclude the other sheet you don't want it to process like this:

    Please Login or Register  to view this content.

    Dom

+ 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