Marge Cells based on Cell value

anjara99

New Member
Joined
May 3, 2020
Messages
8
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have varies list of equipment, I have done background calculation to determine hourly, daily, weekly, or monthly rate will apply to this equipment. I have "D" for daily, "H" for hourly, "W" for weekly, and "M" for monthly.
Based on cell value "W" or "M" I want to merge Week row for weekly rate or all weeks row for a monthly rate. Can you please provide a solution?

I have these cell values in different sheet in the same excel file.

Thank you in Advance.

Rates.jpg
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Right click the sheet tab, select View code, enter this:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Select Case UCase(Target.Value)
Case "M"
If Target.Column = 2 Then
Target.ClearContents
Target.Resize(1, 28).Merge
End If
Case "W"
If Cells(3, Target.Column) = "Monday" Then
Target.ClearContents
Target.Resize(1, 7).Merge
End If
End Select
End Sub
 
Upvote 0
Flour Tracking Sheet-Rev01 - Copy.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXY
1Month 1
2Week 1Week 2Week 3Week 4
3MondayTuesdayWednesdayThrusdaySaturdaySundayMondayTuesdayWednesdayThrusdaySaturdaySundayMondayTuesdayWednesdayThrusdaySaturdaySundayMondayTuesdayWednesdayThrusdaySaturdaySunday
4Labour
5Project Manager
6Superintendent
7Foreman
8Lead Hand
9Operator/ Driver
10Senior Operator
11Trackman
12Equipment
13F150 Pickup
14Crewcab Truck
15Fuel Truck
16Hi-rail Crewcab Truck
17Thermite Welding Truck
18Loader
19Tamper, Switch Chase
20Tamper, Mark IV
21Ballast Regulator
22Production Tie Inserter
23Spiker CX
24Spiker Dual Puller
25Hi-rail Excavator 20k lb to 40k lb
26Hi-rail Excavator 40k lb to 50k lb
27Hi-rail Loader
28Hi-rail Grapple Boom Truck
29Hi-rail HIAB Boom Truck
30Hi-rail Speedswing
31Hi-rail Dump Track
32Highway Tractor /cw Double Drop Trailer
33Tie- Attachment
34Chain Saw / Skill Saw
35Hydraulic Power Pack
36Hydraulic Spiker
37Hydraulic Spike Puller
38Hydraulic Impact
39Hydraulic Tamper
40Hydraulic Rail Drill
41Gas Stockrail Grinder
42Gas Rail Saw
43Gas Tie Drill
44Gas Profile Grinder
45Air Compressor 185 CFM
46Air Impact Wrench
47Air Spikers
48Air Pavement Breaker
49Back Pack Air Blower
50Electric Generator
51Electric 9" Grinder
52Electric Core Drill
53Push Cart
54Thermite Welding Equipment
55Mobile Welder
56Weld Wire Feeder
57Miscellaneous Track Tools
Cost
 
Upvote 0
Can you please explain how would that work, It didn't work for Me
 
Upvote 0
When i copy and paste your program in vba it does not work. am i doing anything wrong
 
Upvote 0
You must copy the code into a Sheet module, not a regular module. Right-click the sheet tab, select View Code, then paste my code there.
 
Upvote 0
It is working, now I have to type "W" or "M" every time, can I relate this to a specific cell from a different sheet that automatically shows "M" or "W"
 
Upvote 0
I have worksheet "Chargeable_Rate" where it shows weekly pop-up as "W" or"W+H" in column I, Column Q, Colum Y, Column AG, Column AO. if it is "w" or "w+h" I want to merge that specific week.
In column AP I have a monthly pop-up as"M" or "M+H" so I want to merge that entire month cells in worksheet "Cost".
Can you please help me with this?
 
Upvote 0

Forum statistics

Threads
1,223,957
Messages
6,175,622
Members
452,661
Latest member
Nonhle

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