+ Reply to Thread
Results 1 to 4 of 4

find and copy paste the value below found word

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-16-2011
    Location
    Philippines
    MS-Off Ver
    Excel 365/Excel 2016
    Posts
    315

    find and copy paste the value below found word

    Hello there, I would like to seek help and advice how can I do it on vba code; I have to find certain word and when it found it will start to copy,start from the found word until the last cell who have data and paste it on another sheet.Is it possible?hope I can get response on this.thanks in advance

  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,259

    Re: find and copy paste the value below found word

    Hello emina002,

    This macro will search "Sheet1" for the string "1234". If Found then the cells below the cell unitl the last entry in that column will be copied to "Sheet2" starting in cell "A1". You can change the sheet names and search word to what you need. Copy and paste this code into a new VBA module in your workbook.

    NOTE: This searches for a whole words and case is ignored. If you need to look for a partial match then change xlWhole to xlPart in the SetMatch statement.

    Sub CopyDataBelowWord()
    
      Dim DstRange As Range
      Dim Match As Range
      Dim Rng As Range
      Dim SrcWks As Worksheet
      Dim Word As String
      
        Word = "1234"
        Set SrcWks = Worksheets("Sheet1")
        Set DstRng = Worksheets("Sheet2").Range("A1")
        
          Set Match = SrcWks.Cells.Find(Word, , xlValues, xlWhole, xlByRows, xlNext, False)
         
          If Not Match Is Nothing Then
             Set Rng = SrcWks.Range(Match.Offset(1, 0), SrcWks.Cells(Rows.Count, Match.Column).End(xlUp))
             Rng.Copy DstRng
          End If
           
    End Sub
    Last edited by Leith Ross; 09-12-2011 at 01:23 PM.
    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
    Forum Contributor
    Join Date
    05-16-2011
    Location
    Philippines
    MS-Off Ver
    Excel 365/Excel 2016
    Posts
    315

    Re: find and copy paste the value below found word

    Thank you, if it's working I will inform you

  4. #4
    Forum Contributor
    Join Date
    05-16-2011
    Location
    Philippines
    MS-Off Ver
    Excel 365/Excel 2016
    Posts
    315

    Re: find and copy paste the value below found word

    it works thank you..

+ 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