+ Reply to Thread
Results 1 to 4 of 4

Populating worksheet B from Worksheet A - VBA help

Hybrid View

  1. #1
    Registered User
    Join Date
    03-21-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    23

    Populating worksheet B from Worksheet A - VBA help

    Hi everyone,
    I have the following scenario:
    I have two worksheets RAW and BOM. What I would like to do is populate the BOM sheet FROM the RAW for certain components.


    For example in BOM worksheet I have VXL5-50 (highlighted in yellow). So for that component, I search sheet1--> 'connector type' column and look if that string exists. If it does, then I increment by 1 in the QTY column in the BOM worksheet

    Pseudocode:
    In BOM worksheet
    	For each Part number
    		Compare with "connector type" in "sheet1"
    		If there is a match
    			Increment "QTY" value by 1 in "BOM" worksheet
    		else move to next row
    		If row in "sheet1" is empty
    			stop script
    Excel file is attached at the bottom

    thank you
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: Populating worksheet B from Worksheet A - VBA help

    Try this...

    Sub Lookup_PNs()
        Dim cell As Range
        For Each cell In Sheets("BOM").Range("A:A").SpecialCells(xlCellTypeConstants)
            If Application.CountIf(Sheets("Sheet1").Range("A:A"), "*" & cell.Value & "*") Then
                cell.Offset(, 2).Value = Application.CountIf(Sheets("Sheet1").Range("A:A"), "*" & cell.Value & "*")
            End If
        Next cell
    End Sub
    Last edited by AlphaFrog; 07-15-2013 at 01:15 AM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Populating worksheet B from Worksheet A - VBA help

    Hi bos1234,
    maybe formula, such as (in C18 sheet 'BOM')
    Formula: copy to clipboard
    =COUNTIF(Sheet1!A2:A27,"*"&A18)

  4. #4
    Registered User
    Join Date
    03-21-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Populating worksheet B from Worksheet A - VBA help

    thanks very much guys.
    @alphafrg - appreciate it. It works fine.

    @nilem - thanks for the easy solution. Appreciate it!

    Not sure which one to adopt. The RAW table will always be different each day/month hence am not sure if countif can be flexible. I think the vba code might solve this issue. I will experiment and see how it goes

    thanks once again!

    regards,
    bos1234
    Last edited by bos1234; 07-15-2013 at 01:29 AM.

+ 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. Replies: 7
    Last Post: 05-22-2013, 04:45 PM
  2. [SOLVED] Need help populating a worksheet based on data from a separate worksheet and column.
    By Rlong1818 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-16-2012, 05:06 PM
  3. Automatically populating cells in a worksheet based on other worksheet column
    By umayank in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-16-2008, 12:33 AM
  4. Populating a column in a worksheet from another worksheet based on a common field
    By p.krembs@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-01-2006, 05:45 AM
  5. Replies: 1
    Last Post: 08-01-2006, 04:45 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