Results 1 to 2 of 2

Basic search/copy/paste - VBA Beginner

Threaded View

ian.saydyk Basic search/copy/paste - VBA... 02-27-2020, 03:35 PM
Richard Buttrey Re: Basic search/copy/paste -... 02-27-2020, 03:41 PM
  1. #1
    Registered User
    Join Date
    02-27-2020
    Location
    Millington, TN
    MS-Off Ver
    2016
    Posts
    1

    Basic search/copy/paste - VBA Beginner

    I am completely new to VBA and am trying to self teach how to write a basic macro to search the data on one work sheet, copy the desired data and paste it to the destination sheet. Here is the code I wrote, can someone explain in two year old terms why it is not working? Thank you

    Sub Search_And_Copy()
    
    'Number of last row that has data
    'r = sheet("NAME OF SEARCH SHEET").Range("A" & rows.count).end(xlup).row
    'Use specific cell for search
    r = Sheets("NAME OF SEARCH SHEET").Cells(Rows.Count, DESIRED SEARCH COLUMN).End(xlUp).Row
    
    For i = r To 1 Step 1
    
        'get last row for destination sheet
        Destination_Last_Row = Sheets("New").Cells(Rows.Count, 1).End(xlUp).Row
    
        'copy data to new worksheet
        Sheets("NAME OF SEARCH SHEET").Cells(i, 1).EntireRow.Copy Sheets("NAME OF DESTINATION SHEET").Cells(Destination_Last_Row + 1, 1)
    
        'copy desired search data
        If Sheets("NAME OF SEARCH SHEET").Cells(i, 4).Value = "SEARCH TERM" Then
        
        'copy data to new worksheet
        Sheets("NAME OF SEARCH SHEET").Cells(i, 1).EntireRow.Copy Sheets("NAME OF DESTINATION SHEET").Cells(Destination_Last_Row + 1, 1)
        
        End If
        
    Next i
    
    End Sub
    Last edited by Richard Buttrey; 02-27-2020 at 03:42 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Basic VBA beginner issue
    By Millso82 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-20-2019, 07:19 PM
  2. Basic beginner questions cross reference
    By Fgsson in forum Excel General
    Replies: 3
    Last Post: 03-28-2019, 04:28 PM
  3. Explaining Basic Code - Finding Average From A Table (Beginner)
    By Tugboat00 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-15-2016, 01:17 AM
  4. Random Letter Copy and paste-Little help for a beginner
    By GerPis in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-02-2012, 09:12 PM
  5. basic formula for an excel beginner
    By Fllyfishy in forum Excel General
    Replies: 4
    Last Post: 11-12-2011, 03:55 PM
  6. [SOLVED] visual basic (copy and paste)
    By ian123 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-07-2006, 06:26 PM
  7. [SOLVED] copy and paste (visual basic)
    By ian123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-07-2006, 06:25 PM

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