Results 1 to 7 of 7

Need to copy from sourcesheet to destination sheet only the new data entered based on seri

Threaded View

Chitaah Need to copy from sourcesheet... 05-18-2021, 01:15 PM
jolivanes Re: Need to copy from... 05-18-2021, 05:29 PM
Chitaah Re: Need to copy from... 05-19-2021, 01:07 AM
Chitaah Re: Need to copy from... 05-19-2021, 02:00 AM
jolivanes Re: Need to copy from... 05-19-2021, 01:54 AM
jolivanes Re: Need to copy from... 05-19-2021, 02:13 AM
Chitaah Re: Need to copy from... 05-19-2021, 02:57 AM
  1. #1
    Registered User
    Join Date
    05-18-2021
    Location
    Kolkata
    MS-Off Ver
    2016
    Posts
    4

    Post Need to copy from sourcesheet to destination sheet only the new data entered based on seri

    I am totally new to Excel VBA. But I have a requirement to copy some data from let us say sheet1 to sheet2. I have several columns and rows in sheet1 (source sheet). Now I have to copy only Five columns data from within that where "Ferro Manganese" found in particular one coloum and if found then just copy the data's from the rows of the other 4 columns also and then paste in to the destination rows of the specified column there in Sheet2. Till this step I have done it successfully. Now the users are entering new data to the source sheet the next day and I only need to update those data to the destination sheet. The new data can be selected based on new Serial no on the sheet1 which is available in coloum "A". For every new entry they enter a increased serial number (Which is unique). so If I can check the "Ferro Manganese" condition from the newly entered serial number (from the point Serial no increased) then I can only copy those new data to the destination sheet using the successful code i am attaching it here. I need to learn how to write that extra if condition for increased serial no condition depending on which the paste function will work for only the new data. Due to office data populated in the sheet I could not upload it. But from the code the description I think you masters will understand it easily.
    Please help me.

    Sub Datafetch()
    
    Dim lastrow As Long, erow As Long
    
    Dim LastRowIndex As Integer
    Dim RowIndex As Integer
    Dim UsedRng As Range
    
    
    lastrow = Worksheets("SIPL Details").Cells(Rows.Count, 1).End(xlUp).Row
    erow = Worksheets("Ferro Tracking").Cells(Rows.Count, 1).End(xlUp).Row
    
    
    For i = 2 To lastrow
    
    If Worksheets("SIPL Details").Cells(i, 7).Value = "Ferro Manganese" Or Worksheets("SIPL Details").Cells(i, 7).Value = "Silico Manganese" Then
    
    Worksheets("SIPL Details").Cells(i, 3).Copy
    Worksheets("SIPL Details").Paste Destination:=Worksheets("Ferro Tracking").Cells(erow + i, 2)
    Worksheets("Ferro Tracking").Cells(erow + i, 1).Value = "SIPL"
    Worksheets("SIPL Details").Cells(i, 7).Copy
    Worksheets("SIPL Details").Paste Destination:=Worksheets("Ferro Tracking").Cells(erow + i, 4)
    Worksheets("Ferro Tracking").Cells(erow + i, 1).Value = "SIPL"
    Worksheets("SIPL Details").Cells(i, 14).Copy
    Worksheets("SIPL Details").Paste Destination:=Worksheets("Ferro Tracking").Cells(erow + i, 7)
    Worksheets("Ferro Tracking").Cells(erow + i, 1).Value = "SIPL"
    Worksheets("SIPL Details").Cells(i, 9).Copy
    Worksheets("SIPL Details").Paste Destination:=Worksheets("Ferro Tracking").Cells(erow + i, 11)
    Worksheets("Ferro Tracking").Cells(erow + i, 1).Value = "SIPL"
    Worksheets("SIPL Details").Cells(i, 5).Copy
    Worksheets("SIPL Details").Paste Destination:=Worksheets("Ferro Tracking").Cells(erow + i, 13)
    Worksheets("Ferro Tracking").Cells(erow + i, 1).Value = "SIPL"
    
    
    
    End If
    
    
    Next i
    
    
    For i = 2 To lastrow
    
    If Worksheets("ESPL Details").Cells(i, 7).Value = "Ferro Manganese" Or Worksheets("ESPL Details").Cells(i, 7).Value = "Silico Manganese" Then
    
    Worksheets("ESPL Details").Cells(i, 3).Copy
    Worksheets("ESPL Details").Paste Destination:=Worksheets("Ferro Tracking").Cells(erow + i, 2)
    Worksheets("Ferro Tracking").Cells(erow + i, 1).Value = "ESPL"
    Worksheets("ESPL Details").Cells(i, 7).Copy
    Worksheets("ESPL Details").Paste Destination:=Worksheets("Ferro Tracking").Cells(erow + i, 4)
    Worksheets("Ferro Tracking").Cells(erow + i, 1).Value = "ESPL"
    Worksheets("ESPL Details").Cells(i, 14).Copy
    Worksheets("ESPL Details").Paste Destination:=Worksheets("Ferro Tracking").Cells(erow + i, 7)
    Worksheets("Ferro Tracking").Cells(erow + i, 1).Value = "ESPL"
    Worksheets("ESPL Details").Cells(i, 9).Copy
    Worksheets("ESPL Details").Paste Destination:=Worksheets("Ferro Tracking").Cells(erow + i, 11)
    Worksheets("Ferro Tracking").Cells(erow + i, 1).Value = "ESPL"
    Worksheets("ESPL Details").Cells(i, 5).Copy
    Worksheets("ESPL Details").Paste Destination:=Worksheets("Ferro Tracking").Cells(erow + i, 13)
    Worksheets("Ferro Tracking").Cells(erow + i, 1).Value = "ESPL"
    
    
    
    End If
    
    
    Next i
    
    
    For i = 2 To lastrow
    
    If Worksheets("BSIPL Details").Cells(i, 7).Value = "Ferro Manganese" Or Worksheets("BSIPL Details").Cells(i, 7).Value = "Silico Manganese" Then
    
    Worksheets("BSIPL Details").Cells(i, 3).Copy
    Worksheets("BSIPL Details").Paste Destination:=Worksheets("Ferro Tracking").Cells(erow + i, 2)
    Worksheets("Ferro Tracking").Cells(erow + i, 1).Value = "BSIPL"
    Worksheets("BSIPL Details").Cells(i, 7).Copy
    Worksheets("BSIPL Details").Paste Destination:=Worksheets("Ferro Tracking").Cells(erow + i, 4)
    Worksheets("Ferro Tracking").Cells(erow + i, 1).Value = "BSIPL"
    Worksheets("BSIPL Details").Cells(i, 14).Copy
    Worksheets("BSIPL Details").Paste Destination:=Worksheets("Ferro Tracking").Cells(erow + i, 7)
    Worksheets("Ferro Tracking").Cells(erow + i, 1).Value = "BSIPL"
    Worksheets("BSIPL Details").Cells(i, 9).Copy
    Worksheets("BSIPL Details").Paste Destination:=Worksheets("Ferro Tracking").Cells(erow + i, 11)
    Worksheets("Ferro Tracking").Cells(erow + i, 1).Value = "BSIPL"
    Worksheets("BSIPL Details").Cells(i, 5).Copy
    Worksheets("BSIPL Details").Paste Destination:=Worksheets("Ferro Tracking").Cells(erow + i, 13)
    Worksheets("Ferro Tracking").Cells(erow + i, 1).Value = "BSIPL"
    
    
    
    End If
    
    
    Next i
    
    
    
    
        Set UsedRng = ActiveSheet.UsedRange
        LastRowIndex = UsedRng.Row - 1 + UsedRng.Rows.Count
        Application.ScreenUpdating = False
     
        For RowIndex = LastRowIndex To 1 Step -1
            If Application.CountA(Rows(RowIndex)) = 0 Then
                Rows(RowIndex).Delete
            End If
        Next RowIndex
     
        Application.ScreenUpdating = True
    
    End Sub
    Last edited by Chitaah; 05-19-2021 at 01:53 AM. Reason: Site rules

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 8
    Last Post: 03-27-2020, 11:39 AM
  2. Copy data from a sheet based on entered product code
    By acad-tra7 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-01-2019, 10:14 AM
  3. [SOLVED] Sub CallMacro to copy data to dest sheet is deleting formula in destination sheet
    By 962371 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-02-2017, 12:38 PM
  4. [SOLVED] copy cell data to another sheet based on month entered
    By steve400243 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-11-2016, 02:48 PM
  5. Copy a row record to a sheet based on the date entered in to a cell
    By Gary Stunell in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-02-2016, 05:23 AM
  6. [SOLVED] Copy Paste a Range of Values from a Different Sheet Based on Value Entered in Cell
    By hamidxa in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-13-2015, 04:53 PM
  7. Copy rows based on criteria to new sheet, controll the destination range.
    By Petter120 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-04-2014, 02:50 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