+ Reply to Thread
Results 1 to 9 of 9

Thread: Extracting Data from Tables

  1. #1
    Registered User
    Join Date
    01-12-2012
    Location
    Glossop, England
    MS-Off Ver
    Excel 2003
    Posts
    4

    Extracting Data from Tables

    Hi guys, I have put together a workbook to prepare quotations for electronic systems which looks something like this (Excel 2010) it's not formatted well in this post, but in this example there are 4 columns headed "Qty", "£ Each", "Description", "Total":-

    Qty £ Each Description Total

    1 £1,500.00 NR1 System Controller £1,500.00
    0 £ 630.50 AR Audio Router
    2 £1,200.00 Audio I/P Interface £2,400.00
    1 £ 929.50 P500 1 x 500 Watt £ 929.50
    0 £1,103.70 P250 1 x 250 Watt
    2 £1,300.00 P125 1 x 125 Watt £2,600.00
    0 £1,183.00 P60 1 x 60 Watt

    It is simple to select the quantity, which then calculates the total, as you can see some items are not included, but having them included in the list for selection acts as an aid de memoir to ensure the correct items are included in the overall system. I have included lots of other functions that automatically calculate the power consumption, equipment rack size, engineering time etc., dependent upon the items included. These figures appear in another tab in the workbook.

    The bit I'm stuck with is this; how can I copy the selected items (values, description, £) and omit those with zero quantity to another sheet, or even Word, so that I can use this to send to the customer.

    I've played around with VLOOKUP and PivotTable, but I'm not getting very far.

    Hope someone can point me in the right direction.

    Thanks,

    Charles
    Attached Files Attached Files
    Last edited by charles.turner@gmx.c; 01-12-2012 at 06:53 AM. Reason: Upload Workbook

  2. #2
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,381

    Re: Extracting Data from Tables

    Its better if you attach a sample workbook than copying the numbers here. Its easier to provide you a solution.
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    01-12-2012
    Location
    Glossop, England
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Extracting Data from Tables

    Hi Arlette, worksheet now attached.

  4. #4
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,381

    Re: Extracting Data from Tables

    Use this code -
    Option Explicit
    Dim lrow As Long
    Dim i As Long
    
    Sub copy_non_zero()
    
    With Worksheets(1)
    
        .Range("D2:K2").copy Worksheets(2).Range("A1")
    
        lrow = .Range("H" & Rows.Count).End(xlUp).Row
        For i = 3 To lrow
            If .Range("D" & i).Value <> "" Then
                .Range("D" & i & ":K" & i).copy Worksheets(2).Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
            End If
        Next i
    End With
    
    End Sub
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  5. #5
    Registered User
    Join Date
    01-05-2012
    Location
    Stavanger
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Extracting Data from Tables

    Thanx, that helps me alot in my project too!
    Last edited by bravo88; 01-12-2012 at 08:48 AM.

  6. #6
    Valued Forum Contributor tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    USA
    MS-Off Ver
    Excel 2003 - 2007
    Posts
    2,352

    Re: Extracting Data from Tables

    Charles,

    You can do this using autofilter, just uncheck "blanks" and then copy/paste data to a new sheet. If you'd like a macro version:
    Sub tgr()
        
        With ActiveSheet.UsedRange
            .AutoFilter 1, "<>"
            .Copy Sheets.Add.Range("A1")
            .AutoFilter
        End With
        
    End Sub
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  7. #7
    Registered User
    Join Date
    01-12-2012
    Location
    Glossop, England
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Extracting Data from Tables

    Thanks, Arlette / tigeravatar, I assume the code goes into VBA. Never used this, so I'll give it a go and keep my fingers crossed!!
    Last edited by charles.turner@gmx.c; 01-12-2012 at 11:23 AM.

  8. #8
    Registered User
    Join Date
    01-12-2012
    Location
    Glossop, England
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Extracting Data from Tables

    Tigeravatar,

    Got your macro to run, couldn't get Arlette's to work!!! Probably my fault (doing something wrong).

    Your macro opens a new sheet and inserts the data into it which is pretty much what I want.

    Just a quick point, how do I get it to open the new sheet with the same formatting as the one it has taken the data from?

    Thanks,

    Charles

  9. #9
    Valued Forum Contributor tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    USA
    MS-Off Ver
    Excel 2003 - 2007
    Posts
    2,352

    Re: Extracting Data from Tables

    Give this a try:
    Sub tgr()
        
        ActiveSheet.Copy Before:=Sheets(1)
        With ActiveSheet.UsedRange
            .AutoFilter 1, "="
            .Offset(1).EntireRow.Delete
            .AutoFilter
        End With
        
    End Sub
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0