+ Reply to Thread
Results 1 to 3 of 3

Help with populating data

Hybrid View

  1. #1
    Registered User
    Join Date
    09-07-2016
    Location
    UK
    MS-Off Ver
    2010
    Posts
    12

    Help with populating data

    Please see attached excel file


    what i want is that on the next sheet, whatever books i have ordered, they should be populated. so maybe a vlookup or something would be the solution? not sure how to go about it..

    please help

    thanks
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,717

    Re: Help with populating data

    try this VBA solution:

    Option Explicit
    
    Sub books()
        Dim sh1 As Worksheet, sh2 As Worksheet
        Set sh1 = Sheets("Sheet1")
        Set sh2 = Sheets("Sheet2")
        Dim lr1 As Long, lr2 As Long, i As Long
        lr1 = sh1.Range("A" & Rows.Count).End(xlUp).Row
        lr2 = sh2.Range("A" & Rows.Count).End(xlUp).Row
        sh2.Range("A1:D" & lr2).ClearContents
        With sh1
            .Range("A1:D1").Copy sh2.Range("A1")
            For i = 2 To lr1
                lr2 = sh2.Range("A" & Rows.Count).End(xlUp).Row
                If .Range("C" & i) <> "" Then
                    .Range("A" & i & ":D" & i).Copy sh2.Range("A" & lr2 + 1)
                End If
            Next i
        End With
    End Sub

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Help with populating data

    This array formula** entered on Sheet2 in cell A2:

    =IF(ROWS(Sheet1!A$2:A2)>COUNT(Sheet1!C:C),"",INDEX(Sheet1!A:A,SMALL(IF(ISNUMBER(Sheet1!C$2:C$16),ROW(Sheet1!C$2:C$16)),ROWS(Sheet1!A$2:A2))))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Copy down until you get blanks.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

+ 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. [SOLVED] Populating forms with new or existing data and saving to a data sheet.
    By u3rick in forum Excel Programming / VBA / Macros
    Replies: 306
    Last Post: 12-01-2015, 02:55 AM
  2. Formula / Macro Help for Populating data and pulling in data
    By crewe2004 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-02-2015, 05:04 PM
  3. Populating Data from the Web
    By mstrchapl in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-07-2014, 12:51 PM
  4. [SOLVED] Populating data into a Summary tab using multiple data tabs
    By S1E in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-14-2013, 09:32 PM
  5. Replies: 2
    Last Post: 03-13-2013, 12:08 PM
  6. Populating Data
    By judge in forum Excel General
    Replies: 4
    Last Post: 09-13-2006, 09:40 AM
  7. [SOLVED] populating excel cells with data from data sources
    By Craig in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2005, 08:50 PM

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