Results 1 to 5 of 5

VBA Macro: Copy range of data to another sheet

Threaded View

  1. #1
    Registered User
    Join Date
    06-26-2015
    Location
    Brazil
    MS-Off Ver
    O365 Win
    Posts
    63

    VBA Macro: Copy range of data to another sheet

    Hi Everyone,

    I am slowly making a new sheet that includes:
    1. A cascading dropdown list done with the help of Dflak here, the cascading dropdown is where I choose the buyer and seller as parent and trader is the person whom I talked to, one company can have multiple traders. (working)
    2. A VBA macro to e-mail PDF through mac Mail, where it will automatically send PDF to my team and also to the buyer (working)
    3. A VBA macro to copy the data (Date, Contract Nr.*, Buyer, Seller, Quality, Price, Volume* and Shipment*)

    Where I am stuck now is on copying the data on the Bold items with *

    We most of the times make sales that are spread throughout different months, and volume can be changed too, so I have:
    • Last Contract number is on cell N5
    • New contract numbers are on range (K18:K31)
    • Volume range(F18:F31)
    • Shipment months range(B18:B31)

    Let's say for instance I am on contract number 10, and I make a new contract that goes from January through March (3 months) and each months has 300 bags. (ranges with data are only 3 columns deep out of 14)

    I have gotten this VBA to copy the data, but how can I make it copy only if there is data, and also include items which not as a range?

    Dim ms As Worksheet, NR
    Set ms = Sheets("historico")
      With Sheets("Sale")
     
    
          NR = ms.Cells.Find("*", , , , xlByRows, xlPrevious).Row + 1
    
    
          If ms.Range("B" & NR - 1) = (Range("K3").Value) Then
              NR = ms.Cells.Find("*", , , , xlByRows, xlPrevious).Row
          End If
    
          ms.Range("A" & NR) = Date
           
           .Range("K18").Resize(3).Copy
           ms.Range("B" & NR).PasteSpecial xlValues, Transpose:=True
           
          .Range("D5").Copy
           ms.Range("C" & NR).PasteSpecial xlValues, Transpose:=True
           
          .Range("K5").Copy
          ms.Range("D" & NR).PasteSpecial xlValues, Transpose:=True
           
           .Range("D13").Copy
           ms.Range("E" & NR).PasteSpecial xlValues, Transpose:=True
           
           .Range("D16").Copy
           ms.Range("F" & NR).PasteSpecial xlValues, Transpose:=True
           
            .Range("D14").Copy
           ms.Range("G" & NR).PasteSpecial xlValues, Transpose:=True
           
            .Range("D12").Copy
           ms.Range("H" & NR).PasteSpecial xlValues, Transpose:=True
           
       
           
         Application.CutCopyMode = False
        
        
        End With
    Attached the full sheet in case it helps you help me :D

    Thanks in advance
    Last edited by danwoltrs; 12-23-2015 at 09:14 AM. Reason: new excel sheet

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 01-22-2014, 05:36 PM
  2. [SOLVED] How to copy data range form one sheet to other sheet with desire Reverse Transpose ?
    By nur2544 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-18-2013, 12:30 PM
  3. Macro to Copy a range from one sheet and sellect where to paste in another sheet
    By Bud Wilkinsonn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-23-2013, 06:49 PM
  4. Macro to copy and paste range form one sheet to next available row in 2nd sheet
    By bajdr47 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-21-2012, 11:47 PM
  5. Replies: 4
    Last Post: 07-24-2012, 07:09 AM
  6. [SOLVED] Search for heading in data sheet and copy range to corresponding sheet in master workbook
    By sans in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-07-2012, 10:02 AM
  7. [SOLVED] Macro: Dynamic creation of sheet based on cell value then copy range to the new sheet
    By BeachRock in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-15-2012, 11:31 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