Return Value based on value in previous cell

clemons171

New Member
Joined
Aug 10, 2016
Messages
25
This may not be possible. What I am looking for is this:

I need a macro that returns values in the cells to the left of the white cells that have text. The value i need returned is the value in the previous darker blue cell. I have included what I would like the end result to look like. the catch is that the amount of rows will vary as you go down the sheet....so it would need to look for the previous cell with that color or the word "Division". Thank You

BEFORE:

Division 05 - Metals
Misc. Metals
Stair - Pan Fill with Landings
Stair Railings - Interior
Wall mounted railing
Bollards
Head Knockers
Misc. Metals
Division 06 - Wood, Plastics, and Composites
Rough Carpentry
Blocking of Door Jambs in CMU
Blocking around Storefront at CMU
Plywood Backerboards
Door Installation
Specialty Installation
Division 07 - Thermal and Moisture Protection
Siding
4" Fiber Cement Siding
Waterproofing and Moisture Barriers
Vehicular Traffic Coating in Garage?
Building Insulation
Insulation under conditioned space
Misc. Spray Foam Throughout as required
Caulking
Misc. Caulking
Division 8 - Openings
Door & Hardware
Single Door HM Frame & Door
Double Door HM Frame & Door
Overhead Doors and Grilles
Overhead Sectional Doors
Glass and Glazing
Storefront
Louvers and Vents
Metal Louver Panels


AFTER:

Division 05 - Metals
Division 05 - Metals
Division 05 - MetalsMisc. Metals
Division 05 - Metals
Division 05 - MetalsStair - Pan Fill with Landings
Division 05 - Metals
Division 05 - MetalsStair Railings - Interior
Division 05 - Metals
Division 05 - MetalsWall mounted railing
Division 05 - Metals
Division 05 - MetalsBollards
Division 05 - Metals
Division 05 - MetalsHead Knockers
Division 05 - Metals
Division 05 - MetalsMisc. Metals
Division 05 - Metals
Division 06 - Wood, Plastics, and Composites
Division 06 - Wood, Plastics, and Composites
Division 06 - Wood, Plastics, and CompositesRough Carpentry
Division 06 - Wood, Plastics, and Composites
Division 06 - Wood, Plastics, and CompositesBlocking of Door Jambs in CMU
Division 06 - Wood, Plastics, and Composites
Division 06 - Wood, Plastics, and CompositesBlocking around Storefront at CMU
Division 06 - Wood, Plastics, and Composites
Division 06 - Wood, Plastics, and CompositesPlywood Backerboards
Division 06 - Wood, Plastics, and Composites
Division 06 - Wood, Plastics, and CompositesDoor Installation
Division 06 - Wood, Plastics, and Composites
Division 06 - Wood, Plastics, and CompositesSpecialty Installation
Division 06 - Wood, Plastics, and Composites
Division 07 - Thermal and Moisture Protection
Division 07 - Thermal and Moisture Protection
Division 07 - Thermal and Moisture ProtectionSiding
Division 07 - Thermal and Moisture Protection
Division 07 - Thermal and Moisture Protection4" Fiber Cement Siding
Division 07 - Thermal and Moisture Protection
Division 07 - Thermal and Moisture ProtectionWaterproofing and Moisture Barriers
Division 07 - Thermal and Moisture Protection
Division 07 - Thermal and Moisture ProtectionVehicular Traffic Coating in Garage?
Division 07 - Thermal and Moisture Protection
Division 07 - Thermal and Moisture ProtectionBuilding Insulation
Division 07 - Thermal and Moisture Protection
Division 07 - Thermal and Moisture ProtectionInsulation under conditioned space
Division 07 - Thermal and Moisture Protection
Division 07 - Thermal and Moisture ProtectionMisc. Spray Foam Throughout as required
Division 07 - Thermal and Moisture Protection
Division 07 - Thermal and Moisture ProtectionCaulking
Division 07 - Thermal and Moisture Protection
Division 07 - Thermal and Moisture ProtectionMisc. Caulking
Division 07 - Thermal and Moisture Protection
Division 8 - Openings
Division 8 - Openings
Division 8 - OpeningsDoor & Hardware
Division 8 - Openings
Division 8 - OpeningsSingle Door HM Frame & Door
Division 8 - Openings
Division 8 - OpeningsDouble Door HM Frame & Door
Division 8 - Openings
Division 8 - OpeningsOverhead Doors and Grilles
Division 8 - Openings
Division 8 - OpeningsOverhead Sectional Doors
Division 8 - Openings
Division 8 - OpeningsGlass and Glazing
Division 8 - Openings
Division 8 - OpeningsStorefront
Division 8 - Openings
Division 8 - OpeningsLouvers and Vents
Division 8 - Openings
Division 8 - OpeningsMetal Louver Panels
Division 8 - Openings
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
You could do a macro, which I could right, but I'd probably do it as a formula using a helper column. Let's say your data is in Column B starting at row 1. In A2, I would do this.

Excel Formula:
=IF(LEFT(B1,8)="Division",B1,A1)

You could then copy/paste that formula down and then paste as values. There are many variations on this so let me know if you have more specific needs.
 
Upvote 0
You could do a macro, which I could right, but I'd probably do it as a formula using a helper column. Let's say your data is in Column B starting at row 1. In A2, I would do this.

Excel Formula:
=IF(LEFT(B1,8)="Division",B1,A1)

You could then copy/paste that formula down and then paste as values. There are many variations on this so let me know if you have more specific needs.
Thank you. So is there an easyway to modify the formula to fill in the 0's with the previous up to where it changes to the next division?

Division 05 - MetalsDivision 05 - Metals
0
0Misc. Metals
0
0Stair - Pan Fill with Landings
0
0Stair Railings - Interior
0
0Wall mounted railing
0
0Bollards
0
0Head Knockers
0
0Misc. Metals
0
Division 06 - Wood, Plastics, and CompositesDivision 06 - Wood, Plastics, and Composites
0
0Rough Carpentry
0
0Blocking of Door Jambs in CMU
0
0Blocking around Storefront at CMU
0
0Plywood Backerboards
0
0Door Installation
0
0Specialty Installation
0
Division 07 - Thermal and Moisture ProtectionDivision 07 - Thermal and Moisture Protection
0
0Siding
0
04" Fiber Cement Siding
0
0Waterproofing and Moisture Barriers
0
0Vehicular Traffic Coating in Garage?
0
0Building Insulation
0
0Insulation under conditioned space
0
0Misc. Spray Foam Throughout as required
0
0Caulking
0
0Misc. Caulking
0
Division 8 - OpeningsDivision 8 - Openings
0
0Door & Hardware
0
0Single Door HM Frame & Door
0
0Double Door HM Frame & Door
0
0Overhead Doors and Grilles
0
0Overhead Sectional Doors
0
0Glass and Glazing
0
0Storefront
0
0Louvers and Vents
0
0Metal Louver Panels
0
 
Upvote 0
My formula should adjust for that. That's what the A1 is for in the false result. Remember, this formula assumes your column data starts in B1, but the formula is in A2.
 
Upvote 0

Forum statistics

Threads
1,214,645
Messages
6,120,711
Members
448,984
Latest member
foxpro

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top