+ Reply to Thread
Results 1 to 6 of 6

Copy a line with a specific key word into another sheet.

Hybrid View

  1. #1
    Registered User
    Join Date
    08-22-2013
    Location
    michigan, USA
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Copy a line with a specific key word into another sheet.

    Hello HaHoBe,
    I tried yours and it said script out of range. Was I meant to change any of the values?

    patel45's worked great but I am wondering if there is a way for the sheets to update automatically as something is entered?

    Anytime I change anything in the log, I will have to delete what is in each sheet and run the macros again for them to be updated without a bunch of duplicate lines.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Copy a line with a specific key word into another sheet.

    Hi, kkihead,

    regarding the run-time error (my bad I didnīt update the code accordingly):
    Sub EF949541_2()
    Dim lngCounter As Long
    
    With Sheets("Log")
      For lngCounter = .Cells(.Rows.Count, "D").End(xlUp).Row To 1 Step -1
        Select Case .Range("D" & lngCounter)
          Case "Bill", "Tim", "Marty", "Dave"
            .Rows(lngCounter).Copy Sheets(.Range("D" & lngCounter).Value).Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
            .Rows(lngCounter).Delete
          Case Else
        End Select
      Next lngCounter
    End With
    
    End Sub
    This code will take away the line from sheet Log. The other way is (as you mentioned) clear contents on all named sheets prior to running the macro, I wouldnīt take the Workjsheet_Change-event to trigger the macro after a change but use the Worksheet_Deactivate - you would need to activate any other sheet to view what has been copied.

    Ciao,
    Holger
    Last edited by HaHoBe; 08-22-2013 at 01:19 PM.
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ 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. Copy table row to another sheet when a specific cell contains the right word
    By robclark89 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-17-2013, 09:53 PM
  2. [SOLVED] Remove a specific word line from a word document.
    By Will_2013 in forum Word Formatting & General
    Replies: 4
    Last Post: 05-26-2013, 07:01 PM
  3. Replies: 1
    Last Post: 04-05-2013, 03:40 PM
  4. Excel VBA copy specific lines from a Word document (3rd line from top of page)
    By Excelebrate in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-25-2012, 06:02 AM
  5. Search word and copy line from multiple sheet to single sheet
    By drtorn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-23-2012, 01:35 AM

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