Solved

How can I work with an Excel spreadsheet using Macro or VLookup?

Posted on 2014-12-18
8
92 Views
Last Modified: 2014-12-29
I would like to work with an Excel spreadsheet using either VLookup or a Macro to accomplish the following:

Column A contains item codes
Column B contains the item code description.
Column C contains the Item the Category.  (some of these will contain a number from 1 to 100, but many are blank, no data.

I would like to sort this data by Category, so that it lists in order, all lines it finds from 1 onward.  Grouping all 1s, 2s, 3s, and so forth, and leaving the blanks at the end after it does not find any more numbers.
0
Comment
Question by:100questions
  • 4
  • 3
8 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40507897
Why not do a sort and then subtotal?

You could always record a macro to copy the sheet, sort then subtotal, and then play it back whenever you want.
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40508069
You could sort and summarize this data using a PivotTable.

The Category would be the primary Row value, followed by the Item Code.

-Glenn
0
 

Author Comment

by:100questions
ID: 40508188
Thanks.  Exactly I am looking for a sample Macro or an example of a Pivot Table for this purpose.
0
 
LVL 27

Accepted Solution

by:
Glenn Ray earned 500 total points
ID: 40508444
Here's an example workbook with data and a PivotTable summary of the items by Category.  

I changed the PivotTable display settings to use the Classic layout so that the Item numbers and descriptions would appear in columns to the side, rather and subcategories below.  (PivotTable Options, Display tab, "Classic PivotTable layout...").  I also turned off subtotalling and hid the columns reserved for the Values (D:I).

Note that any blank categories appear on the bottom of the PivotTable.

Regards,
-Glenn
EE-Q28583684.xlsx
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:100questions
ID: 40522070
Thanks Glenn Ray.  How did you get it to have a Classic layout?  I want to try it with my data.
0
 

Author Comment

by:100questions
ID: 40522247
Glenn Ray.  This seems to work, however it is not recognizing that 100 is not before 11, 12, 13 etc.. and that the number 2 is not after 19, etc..   I imagine that since the 1 or 2 is not entered as 01, or 02, then likely that's why it's not sorting well.
0
 

Author Closing Comment

by:100questions
ID: 40522271
Thanks.  Works, however it is limited based on the numbering in my data 1 instead of 01, therefore it does not list the numbers from 1 to 100 in the correct order.
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40522491
1) Classic Layout:  Right-click anywhere on the PivotTable.  Select "PivotTable Options..."  Click the "Display" tab.  Turn on the check box for "Classic PivotTable layout (enables dragging of fields in the grid)"

2) Your Category values are probably formatted as Text, rather than General/Numbers.  You'll have to change that in the source data in order for the PivotTable to sort them numerically.

-Glenn
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unable to open excel in 2016 is slow 4 21
Excel 2016 - Black cell borders 11 26
Fixing a embedded format 7 29
File not loading into PowerPivot 4 9
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now