+ Reply to Thread
Results 1 to 8 of 8

Transfer data to other sheets VBA

  1. #1
    Registered User
    Join Date
    06-27-2020
    Location
    UAE
    MS-Off Ver
    2013
    Posts
    50

    Transfer data to other sheets VBA

    Hi All,

    I want to transfer all the "a" products to Sheet a, "b" products to Sheet b and "c" products to Sheet c
    considering the id code.
    If the id is already exist in a, b and c Sheets, then those products won't be transferred in order to avoid having duplicate data.

    I have attached the file.
    Thanks in advance
    Attached Files Attached Files

  2. #2
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: Transfer data to other sheets VBA

    <redacted> Will update post.

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

    Re: Transfer data to other sheets VBA

    For workbook uploaded.
    Please Login or Register  to view this content.
    Edit
    Last edited by jindon; 02-16-2023 at 04:00 AM.

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Transfer data to other sheets VBA

    May be:
    PHP Code: 
    Option Explicit
    Sub tranfer
    ()
    Dim lr&, i&, j&, k&, rngrng2idarr()
    Dim dic As Objectws As Worksheet
    Set dic 
    CreateObject("Scripting.Dictionary")
    With Sheets("Data")
        
    lr = .Cells(Rows.Count"B").End(xlUp).Row
        rng 
    = .Range("B6:AA" lr).Value
    End With
    For Each ws In Sheets
        ReDim arr
    (1 To 1000001 To UBound(rng2))
        
    dic.RemoveAll
        With ws
            
    If .Name <> "Data" Then
                lr 
    = .Cells(Rows.Count"B").End(xlUp).Row
                
    If lr 5 Then
                    rng2 
    = .Range("B6:AA" lr).Value
                    
    For 1 To UBound(rng2)
                        
    id rng2(i1) & "|" rng2(i4)
                        If 
    Not dic.exists(idThen dic.Add id""
                        
    For 1 To UBound(rng22)
                            
    arr(ij) = rng2(ij)
                        
    Next
                    Next
                k 
    UBound(rng2)
                
    End If
                For 
    1 To UBound(rng)
                    
    id rng(i1) & "|" rng(i4)
                    If 
    Not dic.exists(id) And rng(i4) = .Name Then
                        k 
    1
                        
    For 1 To UBound(rng2)
                            
    arr(kj) = rng(ij)
                        
    Next
                    End 
    If
                
    Next
                
    .Range("B6:AA100000").ClearContents
                
    .Cells(lr"B").Resize(kUBound(rng22)).Value arr
            End 
    If
        
    End With
    Next
    End Sub 
    Attached Files Attached Files
    Quang PT

  5. #5
    Registered User
    Join Date
    06-27-2020
    Location
    UAE
    MS-Off Ver
    2013
    Posts
    50

    Re: Transfer data to other sheets VBA

    Thank you jindon, it's working supper, can we set the range like, from B to AA columns only please. The data shouldn't be transferred even if there is data after column AA
    Last edited by jalolbek85; 02-16-2023 at 04:34 AM.

  6. #6
    Registered User
    Join Date
    06-27-2020
    Location
    UAE
    MS-Off Ver
    2013
    Posts
    50

    Re: Transfer data to other sheets VBA

    thanks bebo021999, tried the code, but it's keep deleting the date in other a, b, and c sheets, when I run the code more than 1 time.

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

    Re: Transfer data to other sheets VBA

    Try change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-27-2020
    Location
    UAE
    MS-Off Ver
    2013
    Posts
    50

    Re: Transfer data to other sheets VBA

    Thanks a lot jindon, working superb..

+ 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. Two way transfer of data between sheets.
    By X82 in forum Excel General
    Replies: 6
    Last Post: 03-09-2018, 09:45 AM
  2. [SOLVED] Data Transfer Among Sheets
    By Ray Park in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-08-2013, 12:31 PM
  3. data transfer between sheets
    By MikieD in forum Excel General
    Replies: 9
    Last Post: 03-24-2013, 06:27 PM
  4. [SOLVED] VBA. One workbook, 9 sheets, how to transfer data from all sheets to one sheet?
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 05-08-2012, 01:28 PM
  5. Transfer data between sheets
    By billdata in forum Excel General
    Replies: 1
    Last Post: 02-17-2009, 03:21 AM
  6. Data transfer between sheets?
    By Sephiran in forum Excel General
    Replies: 5
    Last Post: 02-15-2009, 03:28 PM
  7. [SOLVED] transfer data between sheets
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-02-2005, 06:35 AM

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