Results 1 to 1 of 1

Need to paste only specific row to another sheet without overwrite

Threaded View

  1. #1
    Registered User
    Join Date
    03-23-2014
    Location
    bangalore
    MS-Off Ver
    Excel 2010
    Posts
    1

    Need to paste only specific row to another sheet without overwrite

    Hi Friends,

    I am a beginer in VBA code. I am working as Field engineer in one firm. For my customer I need to get data for time spend by coverage time. SO I used for loop to get that details from sheet2("CovgDumb") data to sheet1("main") when I entered into coverage name.But if I keep any data in sheet1 except covearage name it will overwrite and paste entire row in sheet1 which I don't want.

    When I call coverage name its only paste specific data which has value in CovgDumb file not any empty rows value nor even entire row.

    It should only call specific rows which has data and it should not overwrite entire data.I am unable to selcet specific range to paste into sheet 2.Please help.

    Sub Macro1()
    
    '
    ' Macro1 Macro
    '
    '   Copies corresponding item# rows from sheet1 worksheet
    '   to sheet2 worksheet by comparing item# column
    If Range("AR6") = "" Then
            Range("AR6").Select
            MsgBox "Please enter a Coverage Name, then try again.", vbExclamation
            Exit Sub
        End If
        Dim rng1 As Range, rng2 As Range
    
    For Each rng1 In Worksheets("CovgDumb").Range("AR3").Resize(Worksheets("CovgDumb").Range("AR3").CurrentRegion.Rows.Count - 1).Rows
      For Each rng2 In Worksheets("Main").Range("AR6").Resize(Worksheets("Main").Range("AR6").CurrentRegion.Rows.Count - 1).Rows
        If rng2(1).Value = rng1(1).Value Then
          rng1.EntireRow.Copy
          rng2.EntireRow.PasteSpecial (xlPasteValues)
        End If
      Next rng2
    Next rng1
    Range("AR6").Select
    End Sub
    Attached Files Attached Files
    Last edited by arlu1201; 04-07-2014 at 11:01 AM. Reason: Code tags as per rule 3.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Copy and paste data from sheet 2 to sheet 1 based on specific criteria on sheet 1
    By VBADUD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2012, 04:18 AM
  2. [SOLVED] Cut and paste overwrite
    By drbig in forum Excel General
    Replies: 5
    Last Post: 09-16-2012, 07:20 AM
  3. [SOLVED] Copy specific range from one sheet and paste to next available row of different sheet
    By koklok in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-28-2012, 07:27 PM
  4. Excel 2007 : Paste Overwrite for Conditional Formatting
    By AdAstraGames in forum Excel General
    Replies: 0
    Last Post: 07-03-2009, 02:30 AM
  5. Sub to copy a target sheet from slaves from and paste/overwrite into master
    By Max in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 06-13-2005, 10:05 PM

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