Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 05-20-2018, 09:05 AM
NoSparks NoSparks is offline Conversion of Columnwise Bill of Material into Rowwise Bill of Material using Excel Macro VBA Windows 7 64bit Conversion of Columnwise Bill of Material into Rowwise Bill of Material using Excel Macro VBA Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Based on your original post and attached file.
You only need to use column B data as your source range.
Code:
Sub TransposeBom()
    Dim lr As Long, rng As Range, cel As Range
    Dim ChildNum As Integer
    Dim destSheet As Worksheet, writeRow As Long
    
With Sheets("Source or Input")
    lr = .Range("B" & Rows.Count).End(xlUp).Row
    Set rng = .Range("B2:B" & lr)
End With

Set destSheet = Sheets("Desired Output")
writeRow = 5   'to keep away from posted desired results

For Each cel In rng
    If cel.Value <> cel.Offset(-1).Value Then
        ChildNum = 1
    Else
        ChildNum = ChildNum + 1
    End If
    
    With destSheet
        If ChildNum = 1 Then
            writeRow = writeRow + 1
            .Cells(writeRow, 1).Resize(, 3).Value = cel.Resize(, 3).Value
            .Cells(writeRow, 4).Resize(, 5).Value = cel.Offset(, 3).Resize(, 5).Value
        Else
            .Cells(writeRow, 4).Offset(, (ChildNum - 1) * 5).Resize(, 5).Value = cel.Offset(, 3).Resize(, 5).Value
        End If
    End With
Next cel
End Sub
Attached Files
File Type: xlsm 1-BomTranspose Macro - Forum.xlsm (19.7 KB, 13 views)
Reply With Quote
 

Tags
bill of materials, bom, transpose



Similar Threads
Thread Thread Starter Forum Replies Last Post
Conversion of Columnwise Bill of Material into Rowwise Bill of Material using Excel Macro VBA BOM (bill of material) umairn Project 1 04-17-2017 02:11 PM
Conversion of Columnwise Bill of Material into Rowwise Bill of Material using Excel Macro VBA Integrating Bill Of Materials (BOM) GRT45 Project 1 03-16-2017 10:26 PM
Conversion of Columnwise Bill of Material into Rowwise Bill of Material using Excel Macro VBA Inserting material after Endnotes ClaireB Word 19 10-01-2015 07:54 PM
Conversion of Columnwise Bill of Material into Rowwise Bill of Material using Excel Macro VBA Project 2013 reading material Steve. Project 3 05-17-2014 07:08 AM
Conversion of Columnwise Bill of Material into Rowwise Bill of Material using Excel Macro VBA Purging duplicated material in a document NepalKat#1 Word 1 09-03-2011 05:53 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:21 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft