+ Reply to Thread
Results 1 to 9 of 9

Copying/Pasting Rows/Columns based on content

  1. #1
    Registered User
    Join Date
    08-24-2006
    Location
    Maryland
    Posts
    50

    Copying/Pasting Rows/Columns based on content

    Good Afternoon!

    I need some serious help with this macro that I am trying to write.

    I have attached the spreadsheet that I am working on. I was trying to write a macro that would cut all of the rows that have "Duplicate claim/service." in column L and paste them into a new worksheet within this workbook. I would also like to cut all of the rows that have a "Y" in column M and paste them into the same worksheet as the "Duplicate claim/services".

    This is a report that is generated daily, the number of rows will vary from day to day. I need this macro to be able to capture ALL of the Duplicate claim/services and ALL of the Y's regardless of how many rows there are in the worksheet.

    This report is a medical claim denial report, all of the "accounts" have to be reviewed EXCEPT for the Duplicate claims and the ones that are marked "Y" for worked.

    I hope this makes sense and I hope someone might be able to help me.

    Thanks,

    Laura S.
    lmsloman@yahoo.com
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    09-14-2006
    Posts
    6
    i had a similar question that i asked for help on... i got some code, but now i need help debugging it.. it doesn't quite work and i'mnot sure why.. here's the thread i started

    http://www.excelforum.com/showthread.php?t=575935

    if you have any ideas on what might be wrong, please let me know too! thanks!!

  3. #3
    Registered User
    Join Date
    08-24-2006
    Location
    Maryland
    Posts
    50
    i had a similar question that i asked for help on... i got some code, but now i need help debugging it.. it doesn't quite work and i'mnot sure why.. here's the thread i started

    http://www.excelforum.com/showthread.php?t=575935

    if you have any ideas on what might be wrong, please let me know too! thanks!!
    HABIB89 :I couldn't figure it out either.....so please, if someone responds to your inquiry, keep me posted. Thanks for your quick response!

  4. #4
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Try this:

    Please Login or Register  to view this content.

    HTH
    Col
    If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.

  5. #5
    Registered User
    Join Date
    08-24-2006
    Location
    Maryland
    Posts
    50
    Try this:


    Code:
    Sub filter_data()

    Dim wshSource As Worksheet, wshDest As Worksheet
    Dim rngCell As Range

    Set wshSource = ActiveSheet
    Set wshDest = Sheets.Add(before:=ActiveSheet)

    wshSource.Select
    For Each rngCell In Intersect([l:l], ActiveSheet.UsedRange)
    If rngCell.Value = "Duplicate claim/service." Or _
    rngCell.Offset(, 1).Value = "Y" Then _
    rngCell.EntireRow.Copy Destination:= _
    wshDest.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
    Next

    [1:1].Copy wshDest.[a1]

    End Sub

    HTH
    Col
    I got an error. Was I supposed to do something other than just paste the code into a new VBA project?

  6. #6
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Paste it into a project, then activate the worksheet with the report on it and run the macro (press Alt+F8 and select it from the list).

    The error was probably down to the activesheet not having an intersection of column L amd the used range.

    And having re-read you're first post, I think my code needs a modification: the original just copied the specified rows to a new sheet; this will cut them:

    Please Login or Register  to view this content.

    C

  7. #7
    Registered User
    Join Date
    08-24-2006
    Location
    Maryland
    Posts
    50
    colofnature: YOU ARE MY HERO!!!

  8. #8
    Registered User
    Join Date
    09-19-2006
    Posts
    1

    a little more help please!

    Hi Col,

    Read this thread with interest since this bit of code seems to be exactly what I need........but.......

    The text string I am looking for is at the beginning of a longer string in the cell - basically I need to test for the presence of "TOTDY" at the beginning of a cell that could contain "TOTDY T-Shirt", "TOTDY Ladies T-Shirt", "TOTDY Gents T-Shirt" etc.

    I have played around with changing the = in the code to Like but without success!

    To sum up, I would like to copy all the rows that contain "TOTDY" at the start of the text in column P to a second worksheet.

    Any help with this would be much appreciated!

  9. #9
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Change

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.

    HTH
    Col

+ 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