+ Reply to Thread
Results 1 to 10 of 10

Find Last Instance of Header, Select to end of Data and copy

  1. #1
    Registered User
    Join Date
    09-19-2018
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    13

    Find Last Instance of Header, Select to end of Data and copy

    Sub FindLast()

    Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet1")
    Dim LCol As Long, Found As Range

    LCol = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
    Set Found = ws.Range(ws.Cells(1, 1), ws.Cells(1, LCol)).Find("Dog", SearchDirection:=xlPrevious)

    If Not Found Is Nothing Then Found.Offset(1, 0).Select

    Range(ActiveCell, ActiveCell.End(xlDown)).Select

    End Sub



    The above is what I have so far, with all but the last line finding the last instance of the header of "Dog" in Sheet1. It's the last line that's causing issues. I have tried every conceivable method of selecting down the column, but I keep getting error 400. Any help appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Find Last Instance of Header, Select to end of Data and copy

    End if missing
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Find Last Instance of Header, Select to end of Data and copy

    Or(I am guessing)

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    09-19-2018
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    13

    Re: Find Last Instance of Header, Select to end of Data and copy

    That hasn't worked. Good spot, but it is still showing the same error message each time.

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Find Last Instance of Header, Select to end of Data and copy

    When I run the code on the attached, I did not get an error. What are you trying to achieve?

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Find Last Instance of Header, Select to end of Data and copy

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-19-2018
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    13

    Re: Find Last Instance of Header, Select to end of Data and copy

    This may make it a bit clearer. I need the macro to find the rightmost column of "Address", copy and paste the data over to the column "Area" in sheet2, with the end goal to be looking as I have it in sheet 3.
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Find Last Instance of Header, Select to end of Data and copy

    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Find Last Instance of Header, Select to end of Data and copy

    I have amended your code. I have also added my own, but prone to error.

  10. #10
    Registered User
    Join Date
    09-19-2018
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    13

    Re: Find Last Instance of Header, Select to end of Data and copy

    Works perfectly, thanks you very much.

+ 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. Replies: 4
    Last Post: 04-07-2017, 01:59 PM
  2. Loop Find Last instance of Values in another Worksheet - then Copy & Paste
    By smartbuyer in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-14-2016, 07:30 PM
  3. [SOLVED] Based on Column Header find and copy data from one sheet to another
    By Sachy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-31-2014, 10:00 AM
  4. Find, select and copy data from specific date
    By Thijsvdberg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-10-2014, 10:54 AM
  5. [SOLVED] To Find every instance of TEXT copy, repeat until no Find found
    By DadaaP in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-25-2013, 02:15 PM
  6. Find&Copy only copying 1 instance of match
    By SarahPintal in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-14-2010, 10:55 AM
  7. [SOLVED] find specific data in row and select and copy entirerow
    By Junior728 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2005, 09:05 AM

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