VBA question for text from isometric drawings

oguztuna

New Member
Joined
Jan 9, 2016
Messages
9
[h=2]VBA for edit text and remove blank rows[/h]
I m finding out <acronym title="visual basic for applications" style="border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: rgb(0, 0, 0); cursor: help;">VBA</acronym> for merging text with a space from below cells which has blank at the next column , and then remove the row that has blanks, as shown below. How can I solve this problem? :confused:

First Form

11.500WT - PIPE SSAWL API 5L BE30PPXC2096207.0M
API-5L-X65M PSL-2 LTD
2SCH80 - PIPE SSAWL API 5L BE API-5L-X65M24PPXC2096191.2M
PSL-2 LTD
3SCH80 - PIPE SSAWL API 5L BE API-5L-X65M18PPXC2096172.3M
PSL-2 LTD
41.500WT - ELL 90 LR WLD MSSSP-75 (PSO)30PCHB115451
BE A860 MSS SP75-WPHY-65
51.500WT - FLG WN MSS-SP-44 BE/RF CL 90030PFWA2657091
A707-L5 CL4

<tbody>
</tbody>


After Edit

11.500WT - PIPE SSAWL API 5L BE API-5L-X65M PSL-2 LTD30PPXC2096207.0M
2SCH80 - PIPE SSAWL API 5L BE API-5L-X65M PSL-2 LTD24PPXC2096191.2M
3SCH80 - PIPE SSAWL API 5L BE API-5L-X65M PSL-2 LTD18PPXC2096172.3M
41.500WT - ELL 90 LR WLD MSSSP-75 (PSO) BE A860 MSS SP75-WPHY-6530PCHB115451
51.500WT - FLG WN MSS-SP-44 BE/RF CL 900 A707-L5 CL430PFWA2657091

<tbody>
</tbody>


Many Thanks,

Tuna​




 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Welcome to the MrExcel board!

Try this in a copy of your workbook.

Original data was in A1:G10.
Macro has produced the data in A14:G18.

Excel Workbook
ABCDEFG
111.500WT - PIPE SSAWL API 5L BE30PPXC2096207.0M
2API-5L-X65M PSL-2 LTD
32SCH80 - PIPE SSAWL API 5L BE API-5L-X65M24PPXC2096191.2M
4PSL-2 LTD
53SCH80 - PIPE SSAWL API 5L BE API-5L-X65M18PPXC2096172.3M
6PSL-2 LTD
741.500WT - ELL 90 LR WLD MSSSP-75 (PSO)30PCHB115451
8BE A860 MSS SP75-WPHY-65
951.500WT - FLG WN MSS-SP-44 BE/RF CL 90030PFWA2657091
10A707-L5 CL4
11
12
13
1411.500WT - PIPE SSAWL API 5L BE API-5L-X65M PSL-2 LTD30PPXC2096207.0M
152SCH80 - PIPE SSAWL API 5L BE API-5L-X65M PSL-2 LTD24PPXC2096191.2M
163SCH80 - PIPE SSAWL API 5L BE API-5L-X65M PSL-2 LTD18PPXC2096172.3M
1741.500WT - ELL 90 LR WLD MSSSP-75 (PSO) BE A860 MSS SP75-WPHY-6530PCHB115451
1851.500WT - FLG WN MSS-SP-44 BE/RF CL 900 A707-L5 CL430PFWA2657091
19
Rearrange




Rich (BB code):
Sub Rearrange()
  Dim a, b
  Dim i As Long, j As Long, k As Long
  
  With Range("A1:G" & Range("C" & Rows.Count).End(xlUp).Row)
    a = .Value
    ReDim b(1 To UBound(a) / 2, 1 To 7)
    For i = 1 To UBound(a) Step 2
      k = k + 1
      For j = 1 To 7
        b(k, j) = a(i, j)
      Next j
      b(k, 3) = b(k, 3) & " " & a(i + 1, 3)
    Next i
    .Offset(.Rows.Count + 3).Resize(k).Value = b
  End With
End Sub
 
Upvote 0
Hi, thanks for this sharing, I d like to know that how this formula works for over 1000 cells and count of blank row is sometimes 3 and sometimes 2 that was given in previous example.:eek:
 
Upvote 0
... count of blank row is sometimes 3 and sometimes 2 that was given in previous example.:eek:
If that means that your previous sample data was not representative of your actual data, then please give another small sample that is representative and also give the expected results again.
 
Upvote 0
Hi,sample that I mentioned is given below.

First Form


SHOP MATERIAL
PTDESCRIPTION NBSPM IDENTQTY
No.(IN)CODE
11.500WT - PIPE SSAWL API 5L BE30PPXC209620 7.0M
API-5L-X65M PSL-2 LTD
2SCH80 - PIPE SSAWL API 5L BE API-5L-X65M24PPXC209619 1.2M
PSL-2 LTD
3SCH80 - PIPE SSAWL API 5L BE API-5L-X65M18PPXC209617 2.3M
PSL-2 LTD
41.500WT - ELL 90 LR WLD MSSSP-75 (PSO)30PCHB115451
BE A860 MSS SP75-WPHY-65
51.500WT - FLG WN MSS-SP-44 BE/RF CL 90030PFWA2657091
A707-L5 CL4
PIPE SUPPORTS
6- Base Support 30-24-BS01-124TT04.6001
7Trunnion Bearing Plate for Acoustic Pad24GT649-6001
24-TG01-E-225 .
8Trunnion Bearing Plate for Acoustic Pad24GT649-6001
24-TG01-E-130 .
9- Trunnion on Straight Pipe18TT17.182
30-18-WA06-1150-1
10Welded Pipe Shoe for LTCS Pipe (-46C to18AT502-4502
+150C) 18-SH04-100-550 .
11Shoe Gusset Plates (Double)18GT510-4502
SG02-329-330-12-170-LTCS Low Temperature
Carbon Steel
ERECTION MATERIALS
PTDESCRIPTION NBSPM IDENTQTY
No.(IN)CODE
PIPE SUPPORTS
12Acoustic Isolation Pad Without Backing24AT533-6002
Plate (Uninsulated Pipe) 24-IS06-200-230
.
13Acoustic Isolation Pad Without Backing24AT533-6002
Plate (Uninsulated Pipe) 24-IS06-100-230
14Special Support24SPECIAL.241
15Pedestal Guide (Heavy Load)24GT665-6001
24-BG06-250-255-20-2-3-10 .
16Pedestal Guide (Heavy Load)24GT665-6001
24-BG06-160-255-20-2-2-6 .
17Acoustic Isolation Pad (Type E) with18AT40E-182
Backing Plate 18-IS07-E-200-200 .
18Shoe Line Stop (Heavy Load)18ST505-4502
18-LS03-210-250-20-2-3-150-6 .
19Special Support18SPECIAL.181
20Acoustic Isolation Pad Without Backing18AT548-4502
Plate (Uninsulated Pipe Stop)
18-IS06-160-200 .

<colgroup><col span="2"><col><col><col><col><col></colgroup><tbody>
</tbody>

Expected Result

SHOP MATERIAL
PTDESCRIPTION NBSPM IDENTQTY
No.(IN)CODE
11.500WT - PIPE SSAWL API 5L BE API-5L-X65M PSL-2 LTD30PPXC209620 7.0M
2SCH80 - PIPE SSAWL API 5L BE API-5L-X65M PSL-2 LTD24PPXC209619 1.2M
3SCH80 - PIPE SSAWL API 5L BE API-5L-X65M PSL-2 LTD18PPXC209617 2.3M
41.500WT - ELL 90 LR WLD MSSSP-75 (PSO) BE A860 MSS SP75-WPHY-6530PCHB115451
51.500WT - FLG WN MSS-SP-44 BE/RF CL 900 A707-L5 CL430PFWA2657091
PIPE SUPPORTS
6- Base Support 30-24-BS01-124TT04.6001
7Trunnion Bearing Plate for Acoustic Pad 24-TG01-E-225 .24GT649-6001
8Trunnion Bearing Plate for Acoustic Pad 24-TG01-E-130 .24GT649-6001
9- Trunnion on Straight Pipe 30-18-WA06-1150-118TT17.182
10Welded Pipe Shoe for LTCS Pipe (-46C to +150C) 18-SH04-100-550 .18AT502-4502
11Shoe Gusset Plates (Double) SG02-329-330-12-170-LTCS Low Temperature Carbon Steel18GT510-4502
ERECTION MATERIALS
PTDESCRIPTION NBSPM IDENTQTY
No.(IN)CODE
PIPE SUPPORTS
12Acoustic Isolation Pad Without Backing Plate (Uninsulated Pipe) 24-IS06-200-230 .24AT533-6002
13Acoustic Isolation Pad Without Backing Plate (Uninsulated Pipe) 24-IS06-100-23024AT533-6002
14Special Support24SPECIAL.241
15Pedestal Guide (Heavy Load) 24-BG06-250-255-20-2-3-10 .24GT665-6001
16Pedestal Guide (Heavy Load) 24-BG06-160-255-20-2-2-6 .24GT665-6001
17Acoustic Isolation Pad (Type E) with Backing Plate 18-IS07-E-200-200 .18AT40E-182
18Shoe Line Stop (Heavy Load) 18-LS03-210-250-20-2-3-150-6 .18ST505-4502
19Special Support18SPECIAL.181
20Acoustic Isolation Pad Without Backing Plate (Uninsulated Pipe Stop) 18-IS06-160-200 .18AT548-4502

<colgroup><col><col><col><col><col></colgroup><tbody>
</tbody>

Many Thanks
 
Upvote 0
Without the borders like you posted in post #1, it's hard to tell what is in what column.

For the original data ..

1. What column is 'SHOP MARERIAL' in?

2. What column is 'DESCRIPTION' in?

3. What column is the heading 'NB' in?

4. Is 'SPM IDENT' in a single cell? Which cell?

5. Some data rows (eg 6 - Base Support...) only have one row. So what logic should we use to decide that 'A707-L5 CL4' is not a stand-alone line like 'PIPE SUPPORTS'?

6. What logic should we use to decide that 'PIPE SUPPORTS' - the first one - (being the second row in that area without an entry in the first column) goes on a line by itself in the results, but 'Carbon Steel' (also being the second row in that area without an entry in the first column) does NOT go on a line by itself but gets combined with the rows above?
 
Upvote 0
Hi,

I specified the columns and rows at below,

The logic is ;

if it s just one data row, I wanna keep it same ,

if it s two data row and next column has one number and one blank cell under this cell , I wanna merge the data rows in one cell which has the number at next column cell.

if it s tree data row, the logic is same as 2 data row. I wanna delete 2 blank row and merge the 3 data rows in one cell.

Basically, I wanna keep the PT. No column numbers and delete blank cells at this column, and I wanna merge the datas which has the blank at next column as given below expected value.

First form

ABCDEFG
1 SHOP MATERIAL
2PT DESCRIPTION NBSPM IDENTQTY
3No. (IN)CODE
41 1.500WT - PIPE SSAWL API 5L BE 30PPXC209620 7.0M
5 API-5L-X65M PSL-2 LTD
62 SCH80 - PIPE SSAWL API 5L BE API-5L-X65M 24PPXC209619 1.2M
7 PSL-2 LTD
83 SCH80 - PIPE SSAWL API 5L BE API-5L-X65M 18PPXC209617 2.3M
9 PSL-2 LTD
104 1.500WT - ELL 90 LR WLD MSSSP-75 (PSO) 30PCHB115451
11 BE A860 MSS SP75-WPHY-65
125 1.500WT - FLG WN MSS-SP-44 BE/RF CL 900 30PFWA2657091
13 A707-L5 CL4
14 PIPE SUPPORTS
156 - Base Support 30-24-BS01-1 24TT04.6001
167 Trunnion Bearing Plate for Acoustic Pad 24GT649-6001
17 24-TG01-E-225 .
188 Trunnion Bearing Plate for Acoustic Pad 24GT649-6001
19 24-TG01-E-130 .
209 - Trunnion on Straight Pipe 18TT17.182
21 30-18-WA06-1150-1
2210 Welded Pipe Shoe for LTCS Pipe (-46C to 18AT502-4502
23 +150C) 18-SH04-100-550 .
2411 Shoe Gusset Plates (Double) 18GT510-4502
25 SG02-329-330-12-170-LTCS Low Temperature
26 Carbon Steel
27 ERECTION MATERIALS
28PT DESCRIPTION NBSPM IDENTQTY
29No. (IN)CODE
30 PIPE SUPPORTS
3112 Acoustic Isolation Pad Without Backing 24AT533-6002
32 Plate (Uninsulated Pipe) 24-IS06-200-230
33 .
3413 Acoustic Isolation Pad Without Backing 24AT533-6002
35 Plate (Uninsulated Pipe) 24-IS06-100-230
3614 Special Support 24SPECIAL.241
3715 Pedestal Guide (Heavy Load) 24GT665-6001
38 24-BG06-250-255-20-2-3-10 .
3916 Pedestal Guide (Heavy Load) 24GT665-6001
40 24-BG06-160-255-20-2-2-6 .
4117 Acoustic Isolation Pad (Type E) with 18AT40E-182
42 Backing Plate 18-IS07-E-200-200 .
4318 Shoe Line Stop (Heavy Load) 18ST505-4502
44 18-LS03-210-250-20-2-3-150-6 .
4519 Special Support 18SPECIAL.181
4620 Acoustic Isolation Pad Without Backing 18AT548-4502
47 Plate (Uninsulated Pipe Stop)
48 18-IS06-160-200 .

<colgroup><col span="2"><col><col><col><col><col><col></colgroup><tbody>
</tbody>

Expected Value

ABCDEFG
1 SHOP MATERIAL
2PT DESCRIPTION NBSPM IDENTQTY
3No. (IN)CODE
41 1.500WT - PIPE SSAWL API 5L BE API-5L-X65M PSL-2 LTD 30PPXC209620 7.0M
62 SCH80 - PIPE SSAWL API 5L BE API-5L-X65M PSL-2 LTD 24PPXC209619 1.2M
83 SCH80 - PIPE SSAWL API 5L BE API-5L-X65M PSL-2 LTD 18PPXC209617 2.3M
104 1.500WT - ELL 90 LR WLD MSSSP-75 (PSO) BE A860 MSS SP75-WPHY-65 30PCHB115451
125 1.500WT - FLG WN MSS-SP-44 BE/RF CL 900 A707-L5 CL4 30PFWA2657091
14 PIPE SUPPORTS
156 - Base Support 30-24-BS01-1 24TT04.6001
167 Trunnion Bearing Plate for Acoustic Pad 24-TG01-E-225 . 24GT649-6001
188 Trunnion Bearing Plate for Acoustic Pad 24-TG01-E-130 . 24GT649-6001
209 - Trunnion on Straight Pipe 30-18-WA06-1150-1 18TT17.182
2210 Welded Pipe Shoe for LTCS Pipe (-46C to +150C) 18-SH04-100-550 . 18AT502-4502
2411 Shoe Gusset Plates (Double) SG02-329-330-12-170-LTCS Low Temperature Carbon Steel 18GT510-4502
27 ERECTION MATERIALS
28PT DESCRIPTION NBSPM IDENTQTY
29No. (IN)CODE
30 PIPE SUPPORTS
3112 Acoustic Isolation Pad Without Backing Plate (Uninsulated Pipe) 24-IS06-200-230 . 24AT533-6002
3413 Acoustic Isolation Pad Without Backing Plate (Uninsulated Pipe) 24-IS06-100-230 24AT533-6002
3614 Special Support 24SPECIAL.241
3715 Pedestal Guide (Heavy Load) 24-BG06-250-255-20-2-3-10 . 24GT665-6001
3916 Pedestal Guide (Heavy Load) 24-BG06-160-255-20-2-2-6 . 24GT665-6001
4117 Acoustic Isolation Pad (Type E) with Backing Plate 18-IS07-E-200-200 . 18AT40E-182
4318 Shoe Line Stop (Heavy Load) 18-LS03-210-250-20-2-3-150-6 . 18ST505-4502
4519 Special Support 18SPECIAL.181
4620 Acoustic Isolation Pad Without Backing Plate (Uninsulated Pipe Stop) 18-IS06-160-200 . 18AT548-4502

<colgroup><col span="2"><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
Try
Rich (BB code):
Sub Rearrange_v2()
  Dim a, b
  Dim i As Long, j As Long, k As Long
  
  With Range("A1:G" & Range("C" & Rows.Count).End(xlUp).Row)
    a = .Value
    ReDim b(1 To UBound(a), 1 To 7)
    For i = 1 To UBound(a)
      Select Case True
        Case a(i, 3) = "", a(i, 1) <> ""
          k = k + 1
          For j = 1 To 7
            b(k, j) = a(i, j)
          Next j
        Case Else
          b(k, 3) = b(k, 3) & " " & a(i, 3)
      End Select
    Next i
    .Offset(.Rows.Count + 3).Resize(k).Value = b
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,200
Messages
6,123,604
Members
449,109
Latest member
Sebas8956

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