Results 1 to 3 of 3
  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2018

    Need to use VBA to copy data from a workbook into my workbook based on matching crite

    48 x 40 4way .5 GMA.xml35 x 45 2way.xml

    I am hoping one of the guru's here can help me (or even a non-guru ). I know just enough to be dangerous, but not enough to do what i need.

    I am trying to use VBA to extract the thickness, width, and length for each of the 3 components that make up a pallet from an export i get (2 attachments). I want to export the data into a pricing sheet i use, it will save considerable time and errors that occur from typing them in.

    I need VBA to allow me to open a .xml file (i attached 2 example), then insert the component dimensions into my pricing sheet. I tried uploading my pricing sheet, but the site will not allow me to. It is a pretty simple sheet, i put a screen shot below. One issue is sometimes there are 2 width boards on top or bottom, so i need VBA to recognize that and insert either 2 sizes on the top and bottom or just one size. The two files i was able to attach show an example of each.

    I have the code below that allows me to select the file i want to import data from, but i am lost from there...
    I really appreciate any help!! Thank you!!
    Option Explicit
    Sub test2()
        Dim wb As Workbook, wb2 As Workbook
        Dim ws As Worksheet
        Dim vFile As Variant
        'Set source workbook
        Set wb = ActiveWorkbook
        'Open the target workbook
        vFile = Application.GetOpenFilename("Excel-files,*.xml", _
            1, "Select One File To Open", , False)
        'if the user didn't select a file, exit sub
        If TypeName(vFile) = "Boolean" Then Exit Sub
        Workbooks.Open vFile
        'Set targetworkbook
        Set wb2 = ActiveWorkbook
    End Sub
    Name:  Capture.JPG
Views: 124
Size:  28.1 KB
    Last edited by Shaggy Hiker; Feb 14th, 2018 at 08:33 PM. Reason: Added CODE tags.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Sydney, Australia

    Re: Need to use VBA to copy data from a workbook into my workbook based on matching c

    If you need to use VBA then you ought to post in the forum dedicated to VBA rather than the one dedicated to VB.NET. I've asked the mods to move this thread to the proper place.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Java (JSP) Hell!

    Re: Need to use VBA to copy data from a workbook into my workbook based on matching c

    When you open the file, specify read only and xml type. It should open to a new sheet/workbook.
    Then you should be able to get a reference and find the columns/rows to get the data.

    If you are that new, check the first few threads at the top of the forum, there should be links to tutorials to assist you.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.