Hello people of the Excel Help Forum.
I'm a new member and this problem is one of the main factors for my membership.
I am trying to write a macro, but running into some difficulty. I have an excel workbook that contains one sheet, “Labor,” with the following information.
A B C D E F G H
1 Order No., Cost Elem, Cost Elem Name, ID Number, Cost Center, Amount, Quantity, and Posting Date
2 333458312 ... ... SAL-MGMT S/T ... ... ... ...
3 333458312 ... ... SAL-UNION S/T ... ... ... ...
4 333458312 ... ... EMP TRVL-MEALS/ENT... ... ... ...
and so on. I am going to run this macro on multiple spreadsheets (but only one at a time). They all have 8 columns, but the numbers of rows vary (aka dynamic range). The column I care about is C (Cost Element Name). I want to make a new tab for all of the different labor types.
There are several cost element names, but I only care about 5 of them. They are: “SAL-MGMT S/T”, “SAL-CLERICAL/TECH ST”, “SAL-UNION S/T”, “SAL-TEMP P-T S/T”, and “SRV-TEMP AGNCY LABOR.” The five cost element names fall into 4 different categories: MGMT Labor, CT Labor (contains CLERICAL/TECH labor and TEMP P-T), Union Labor, and Agency Labor. I want the new spreadsheets in the same workbook and named after the four categories. So all the Union labor would be in the “Union Labor” sheet along with all the information in their row. Also, if the Cost Element Name does not fall under one of the five names I want, I want that row deleted (My example row #4 would be deleted since the cost element name is EMP TRVL-MEALS/ENT.)
I’ve tried adapting the code from the answer to this question (http://www.computing.net/answers/off...ets/13596.html), but I keep getting this error, “Runtime '1004' application-defined or object-defined error” for the line that reads ActiveSheet.Name = rateName.
Here is my code:
![]()
Please Login or Register to view this content.
Bookmarks