+ Reply to Thread
Results 1 to 3 of 3

Search errors triggered by each record/row.

Hybrid View

  1. #1
    Registered User
    Join Date
    03-10-2010
    Location
    kampala, uganda
    MS-Off Ver
    Excel 2007
    Posts
    15

    Question Search errors triggered by each record/row.

    Hi,
    Halo everyone? Can i humbly bring your attention to an Excel programming problem i seek:
    In Sheet1 I have data on a couple of records with information like 'Business Name', 'Credit Application date' etc. against each record (row) are listed errors triggered (from column R).
    I would like to list the same data in different sheets, separating the records by the errors they have triggered (each sheettab name is the error's name, e.g. error1, error2...).
    Could anyone help me do this with a macro?

    bryenWalt
    Attached Files Attached Files
    Last edited by bryenwalt; 03-29-2010 at 05:18 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Search errors triggered by each record/row.

    Hello bryenwalt,

    The following macro has been added to the attached workbook. It will copy the data to the error sheets.
    Sub CopyToErrorSheets()
    
      Dim Cell As Range
      Dim DstRng As Range
      Dim DstWks As Worksheet
      Dim ErrCells As Range
      Dim Info As Variant
      Dim R As Long
      Dim RngEnd As Range
      Dim SrcRng As Range
      Dim SrcWks As Worksheet
      
        Set SrcWks = Worksheets("Cap")
        
        Set SrcRng = SrcWks.Range("A2:P2")
        Set RngEnd = SrcWks.Cells(Rows.Count, SrcRng.Column).End(xlUp)
        
        If RngEnd.Row < SrcRng.Row Then
          MsgBox "This sheet contains no data."
          Exit Sub
        End If
        
        Set SrcRng = SrcWks.Range(SrcRng, RngEnd)
        
        Set ErrCells = SrcWks.Range("R2:V" & SrcRng.Rows.Count + 2 - 1)
        
          For R = 1 To SrcRng.Rows.Count
            Info = SrcRng.Rows(R).Value
              For Each Cell In ErrCells.Rows(R).Cells
                If Cell.Text <> "" Then
                  Set DstWks = Worksheets(Cell.Text)
                    Set DstRng = DstWks.Range("A3")
                    Set RngEnd = DstWks.Cells(Rows.Count, DstRng.Column).End(xlUp)
                    Set DstRng = IIf(RngEnd.Row < DstRng.Row, DstRng, RngEnd.Offset(1, 0))
                  DstRng.Resize(1, 16).Value = Info
                End If
             Next Cell
          Next R
          
    End Sub
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    03-10-2010
    Location
    kampala, uganda
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Search errors triggered by each record/row.

    A very amazing solution. I'm enternally greatful for this considerable help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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