+ Reply to Thread
Results 1 to 10 of 10

Find every cell in a sheet that isn't zero and make a list incl. other cells in row

  1. #1
    Registered User
    Join Date
    12-04-2017
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    16

    Find every cell in a sheet that isn't zero and make a list incl. other cells in row

    Hi guys, just trying to work out if something is possible or not.

    Our customers send us templates that are not in a standard format. I need to convert the 2 dimension sheets into a flat file with just the cells that have a non zero value.

    What is consistent is that each row has a name in the first column and it needs to bring back that name, the column header and the value for each cell that isn't zero.

    I'm not asking for someone to code this for me. Just want to know if a task like this is achievable before diving in.

    Thanks for your help.

    Regards HT

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Find every cell in a sheet that isn't zero and make a list incl. other cells in row

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,535

    Re: Find every cell in a sheet that isn't zero and make a list incl. other cells in row

    With the meager info, try this (Change references as required.)
    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,535

    Re: Find every cell in a sheet that isn't zero and make a list incl. other cells in row

    If your layout is as in Post #3, this should be faster if you have a large range.
    Again, change references as required
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-04-2017
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    16

    Re: Find every cell in a sheet that isn't zero and make a list incl. other cells in row

    Quote Originally Posted by mike7952 View Post
    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Hi Mike, and thanks for your help.

    I have attached some sanitized sample data - sheet1 shows a report from a customer that I'm trying to get into the list format. Sheet2 shows an example of the output I would need. Any pointers would be greatly appreciated.

    Thanks again.
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,560

    Re: Find every cell in a sheet that isn't zero and make a list incl. other cells in row

    This should do.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-04-2017
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    16

    Re: Find every cell in a sheet that isn't zero and make a list incl. other cells in row

    Quote Originally Posted by jindon View Post
    This should do.
    Please Login or Register  to view this content.
    Thanks Jindon, that certainly worked

    Just a quick follow up iof I may because I'm not just here to take other peoples work but also to try and understand the code. How would I go about adding an additional column of data to evaluation process?

    So at the moment I get what the code is doing - looking at columns 2,4,8,9 so adding another colum to that list is obvious but i'm a bit lost with the loop section and the 'i','ii' & "iii" bit - I think I need to add something here but I'm confused how that section is working.

    Thanks again. You guys are so helpful.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,560

    Re: Find every cell in a sheet that isn't zero and make a list incl. other cells in row

    The code is a extract of col.B, D, H & I from the data range into an array "a"
    Please Login or Register  to view this content.
    So, 1st row of Array a looks like "EE's Ref", "Surname", "Annual Salary" and "Annual Car Allowance"
    Code loop from 3rd column to 4th column and down from row2 to the end of the row evaluating if the element is not 0 and not empty.
    When something in there, put the relevant values to array "b" (for the output).

    If you want to add columns to be evaluated, just add coloumn reference to the array like
    Please Login or Register  to view this content.
    and change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    So that the code will loop from the 3rd column to the end.

    HTH

  9. #9
    Registered User
    Join Date
    12-04-2017
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    16

    Re: Find every cell in a sheet that isn't zero and make a list incl. other cells in row

    Thats brilliant Jindon, Thanks so much.

    I just needed to also change:

    ReDim b(1 To UBound(a, 1) * 2, 1 To 4) to reflect the number of columns and it worked.

    Really appreciate the time and effort in helping me guys.

    I'll marked this as solved.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,560

    Re: Find every cell in a sheet that isn't zero and make a list incl. other cells in row

    That's good to hear.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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] retrieve value from list based on 2 criteria incl date
    By kammend in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 04-05-2016, 09:12 AM
  2. Replies: 2
    Last Post: 11-13-2015, 10:14 AM
  3. [SOLVED] List All Changed Excel Files Today On Drive And Hyperlink (Incl. Subfolders)
    By alienware in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2014, 03:18 AM
  4. How to automatically put quotes around contents of every cell, incl. blank cells?
    By willcoq in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-13-2014, 03:15 PM
  5. Enter data in a cell to make a list on another sheet
    By tah2x in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-10-2013, 03:48 AM
  6. Replies: 3
    Last Post: 11-18-2005, 05:00 PM
  7. find text in a cell and make cell 2 cells below that active
    By shark102 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-20-2005, 10:05 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