VBA Conditional Cell Merge

mamyers64

New Member
Joined
Feb 11, 2016
Messages
17
I need to perform a conditional cell merge. I assume it will require VBA. The data is the result of an external SQL query. The final product in this example is the body of a Work Order Detail. I will only be displaying one WO at a time; user will view and or Print, so it needs to fit on a single sheet (Vertical 8.5*11). The Pervasive SQL table contains a longvarchar field; the data contains carriage returns (char(10)) in order to achieve the desired formatting. When I apply Wrap Text to column G I get the results in the top example. However based on the value in B5 = "N" I want to merge cells D5:G5 and I want to resize the row so I can see all the text and not waste space. The second example is what I want it to look like. Given this is a query results it is impossible to foretell which rows will have the "N" in column B or how many there will be.
A
B
C
D
E
F
G
1
Line
LMO
PART_WC_OUTSIDE
Set_Up
Run_Time/Qty
Line_Desc
Subset_Spec
2
000100
M
407
0.0012
0.0004
70a NBR-SULFUR
3
000101
C
MS-407 REV.A
4
000150
L
MOLD
0.033
MOLD PULL & CLEAN
5
000158
N
DM_File_Name: SQS-00028.pdf DM_Description: NPT QUALITY STAND DM_From_Date: 2006-06-01
DM_Rev: C DM_Status: A DM_Type: :Cust Spec DM_Customer: Myers Ent DM_To_Date:

4.0 INSPECTION METHODS AND REQUIREMENTS

4.1.Functional Thread Size: Acceptance of thread size is determined from the measured standoff
ANPT gage plugs and rings. Standoffis to be measured with a suitable depth indicator to the .
Counting of turns is to be avoided unless linear measurement is impractical. Gage standoff,
is to be added to the measured standoff of the gaged part to derive the true standoff value.
NOTE: Variable-type gaging may be used as an analytical tool for process control but
to determine final acceptance.

<tbody>
</tbody>

A
B
C
D
E
F
G
1
Line
LMO
PART_WC_OUTSIDE
Set_Up
Run_Time/Qty
Line_Desc
Subset_Spec
2
000100
M
407
0.0012
0.0004
70a NBR-SULFUR
3
000101
C
MS-407 REV.A
4
000150
L
MOLD
0.033
MOLD PULL & CLEAN
5
000158
N
DM_File_Name: SQS-00028.pdf DM_Description: NPT QUALITY STANDARD DM_From_Date: 2006-06-01
DM_Rev: C DM_Status: A DM_Type: :Cust Spec DM_Customer: Myers Enterprise DM_To_Date:

4.0 INSPECTION METHODS AND REQUIREMENTS

4.1.Functional Thread Size: Acceptance of thread size is determined from the measured
ANPT gage plugs and rings. Standoffis to be measured with a suitable depth indicator to the
Counting of turns is to be avoided unless linear measurement is impractical. Gage standoff, per
is to be added to the measured standoff of the gaged part to derive the true standoff value.
NOTE: Variable-type gaging may be used as an analytical tool for process control but is not
to determine final acceptance.

<tbody>
</tbody>
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
I've concluded it can't be done, at least not for free on a message board. This is due to the data dynamic nature, not knowing where the range of cell with be that need merging. So, I created a workaround/better report design so I can still accomplish the objective.
 
Upvote 0

Forum statistics

Threads
1,215,440
Messages
6,124,882
Members
449,193
Latest member
PurplePlop

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