Hi,
I have attached one small example what i need in macro .kindly help me out of my problem.
if any one can solve my issue that will be more appreciate
Short and split common multicolumn value
-
-
Re: Short and split common multicolumn value
- What is the problem?
- What have you tried?This is extremely vague, and without any detail you will probably find people are unwilling to look any further. Please explain fully in your post what you are looking to achieve and what you think is stopping you from achieving it.
-
Re: Short and split common multicolumn value
Dear Sir,
Thanks for your reply .I am trying to extra explain in attached file.Its working fine with me.
I used macro I column with split separate sheets.
Now I need additional macro code for below details:Now:
[tr]
[TABLE="class: grid, width: 500, align: left"]
[td]Date
[/td]
[td]M/C No
[/td]
[td]P.O No
[/td]
[td]Drg No
[/td]
[td]Drg Name
[/td]
[td]Operation No
[/td]
[td]M/c Time
[/td]
[td]Load time
[/td]
[td]Total Time
[/td]
[td]Shif A
[/td]
[/tr]
[tr]
[td]1
[/td]
[td]M2
[/td]
[td]1.1
[/td]
[td]DRG1
[/td]
[td]DF
[/td]
[td]1
[/td]
[td]10
[/td]
[td]2
[/td]
[td]12
[/td]
[td]10
[/td]
[/tr]
[tr]
[td]1
[/td]
[td]M2
[/td]
[td]1.1
[/td]
[td]DRG1
[/td]
[td]DF
[/td]
[td]1
[/td]
[td]10
[/td]
[td]2
[/td]
[td]12
[/td]
[td]20
[/td]
[/tr]
[tr]
[td]2
[/td]
[td]M3
[/td]
[td]1.2
[/td]
[td]DRG2
[/td]
[td]DG
[/td]
[td]1
[/td]
[td]5
[/td]
[td]3
[/td]
[td]8
[/td]
[td]20
[/td]
[/tr]
[tr]
[td]2
[/td]
[td]M3
[/td]
[td]1.2
[/td]
[td]DRG2
[/td]
[td]DG
[/td]
[td]2
[/td]
[td]4
[/td]
[td]1
[/td]
[td]5
[/td]
[td]50
[/td]
[/tr]
[/TABLE]After
[TABLE="class: grid, width: 500, align: left"]
[tr]
[td]Date
[/td]
[td]M/C No
[/td]
[td]P.O No
[/td]
[td]Drg No
[/td]
[td]Drg Name
[/td]
[td]Operation No
[/td]
[td]M/c Time
[/td]
[td]Load time
[/td]
[td]Total Time
[/td]
[td]Shif A
[/td]
[td]Shif B
[/td]
[/tr]
[tr]
[td]1
[/td]
[td]M2
[/td]
[td]1.1
[/td]
[td]DRG1
[/td]
[td]DF
[/td]
[td]1
[/td]
[td]10
[/td]
[td]2
[/td]
[td]12
[/td]
[td]10
[/td]
[td]20
[/td]
[/tr]
[tr]
[td]2
[/td]
[td]M3
[/td]
[td]1.2
[/td]
[td]DRG2
[/td]
[td]DG
[/td]
[td]1
[/td]
[td]5
[/td]
[td]3
[/td]
[td]8
[/td]
[td]20
[/td]
[td][/td]
[/tr]
[tr]
[td]2
[/td]
[td]M3
[/td]
[td]1.2
[/td]
[td]DRG2
[/td]
[td]DG
[/td]
[td]2
[/td]
[td]4
[/td]
[td]1
[/td]
[td]5
[/td]
[td][/td]
[td]50
[/td]
[/tr]
[/TABLE]If column 1 to column 6 is same data then Shift B data will come in after shift A coloumn.
So Kindly convert my macro code
Code
Display MoreDim lastrow As Long, nextrow As Long, c As Range, strName As String, ws As Worksheet Application.ScreenUpdating = False With Sheet1 'code name for master sheet '// determine the last data row using column-E Company Name lastrow = .Cells(Rows.Count, "g").End(xlUp).Row '// turn of any existing filter .AutoFilterMode = False '// clear the paste range to receive unique list of company names in subsequent filter action .Range("At2").EntireColumn.ClearContents .Range("i2:i" & lastrow).AdvancedFilter action:=xlFilterCopy, copytorange:=.Range("at2"), Unique:=True .AutoFilterMode = False On Error Resume Next '// loop through the list of unique company names and pass each value in turn to subsequent filters and copy data to company sheet For Each c In .Range("at2:at" & .Cells(Rows.Count, "at").End(xlUp).Row) strName = c.Value Set ws = Sheets(strName) '// Test to see that a sheet for the company name exist before attempting to copy data If ws Is Nothing Then 'company sheet does not exist, create new sheet With ThisWorkbook .Worksheets.Add(after:=Sheets(Sheets.Count)).Name = strName End With End If '// define the next available empty row on the target company sheet nextrow = Worksheets(strName).Cells(Rows.Count, "A").End(xlUp).Row + 1 '// apply the autofilter and copy visible cells .Range("i2:i" & lastrow).AutoFilter field:=1, Criteria1:=strName .Range("g2:ao" & lastrow).Offset(0, 0).SpecialCells(xlCellTypeVisible).Copy '// paste as value to the target company sheet With Worksheets(strName) .Range("A" & nextrow).PasteSpecial xlPasteValuesAndNumberFormats End With Application.CutCopyMode = False Set ws = Nothing Next c .AutoFilterMode = False End With Application.ScreenUpdating = True
Quote from S O;743850- What is the problem?
- What have you tried?This is extremely vague, and without any detail you will probably find people are unwilling to look any further. Please explain fully in your post what you are looking to achieve and what you think is stopping you from achieving it.
-
Re: Short and split common multicolumn value
Hi genius kindly help me out of my problem
-
Re: Short and split common multicolumn value
Try this:-
NB:- Your data is assumed to start in "A1" Reference the header word "Date".
The results start Sheet2 "A1".Code
Display MoreSub DataSort() Dim Dn As Range, txt As String, Rng As Range Dim Dic As Object, k As Variant Dim p As Variant, c As Long Dim col1 As Integer, col2 As Integer Set Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp)) ReDim Ray(1 To Rng.Count, 1 To 11) Set Dic = CreateObject("Scripting.Dictionary") Dic.CompareMode = 1 For Each Dn In Rng txt = Dn & "," & Dn.Offset(, 1) & "," & Dn.Offset(, 3).Value & "," & Dn.Offset(, 4).Value & "," & Dn.Offset(, 5).Value If Not Dic.exists(txt) Then Set Dic(txt) = CreateObject("Scripting.Dictionary") End If If Not Dic(txt).exists(Dn.Offset(, 2).Value) Then Dic(txt).Add (Dn.Offset(, 2).Value), Dn Else Set Dic(txt).Item(Dn.Offset(, 2).Value) = _ Union(Dic(txt).Item(Dn.Offset(, 2).Value), Dn) End If Next Dn c = 2 Ray(1, 1) = "Date": Ray(1, 2) = "M/C No": Ray(1, 3) = "PO.No": Ray(1, 4) = "Drg No" Ray(1, 5) = "Drg Name": Ray(1, 6) = "OPERATOR NAME": Ray(1, 8) = "M/C Time": Ray(1, 9) = "L/UL Time": Ray(1, 10) = "production" Ray(2, 6) = "A": Ray(2, 7) = "B": Ray(2, 8) = "Mint.": Ray(2, 9) = "Mint.": Ray(2, 10) = "Shift A": Ray(2, 11) = "Shift B" For Each k In Dic.Keys c = c + 1 For Each p In Dic(k) Ray(c, 1) = Dic(k).Item(p) Ray(c, 2) = Dic(k).Item(p).Offset(, 1).Value Ray(c, 3) = Dic(k).Item(p).Offset(, 3).Value Ray(c, 4) = Dic(k).Item(p).Offset(, 4).Value Ray(c, 5) = Dic(k).Item(p).Offset(, 5).Value col1 = IIf(p = "A", 6, 7) Ray(c, col1) = Dic(k).Item(p).Offset(, 7).Value Ray(c, 8) = Dic(k).Item(p).Offset(, 8).Value Ray(c, 9) = Dic(k).Item(p).Offset(, 9).Value col2 = IIf(p = "A", 10, 11) Ray(c, col2) = Dic(k).Item(p).Offset(, 10).Value Next p Next k With Sheets("Sheet2").Range("A1").Resize(c, 11) .Value = Ray .Columns.AutoFit .Range("F1:G1").MergeCells = True .Range("F1").HorizontalAlignment = xlCenter .Range("J1:K1").MergeCells = True .Range("J1").HorizontalAlignment = xlCenter End With End Sub
-
-
Re: Short and split common multicolumn value
Daer Mr.MickG,
Thanks for your reply and gave me your valuable time .
Kindly see the example file ,How I need explained detail in sheetnow.If column A to column I is same then data should be split in accordingly date,machine and shift reference in same line.
if column A to column I if different in any data then A shift data will go shift A column in respectively heading.kindly change code accordingly.
Thanks in Advance.god_karthi
-
Re: Short and split common multicolumn value
Please supply a more comprehensive "After" sheet. Your requirements are not too clear from the limited data shown.
-
Re: Short and split common multicolumn value
Dear Mr.MickG,
Once more I grate thanks full to you for spend your valuable time.I explain more to this time in attached file with "After" Sheet.I hope in this time you will understand what I am required.Actually this is Production report consolidated with respect to machine ,Date,Item,Shift wise.
my data will constant row with "Column A to Column I". after that data will change accordingly in shift wise.(same data then come same row,different data different row with shift A or Shift B wise).
same data will be available only two rows only (not available more that two row).- If Master sheet "Column A to Column I" data is same then (Green color) data will change as shown green color .Master Sheet Column J will shifted to each category Like shift A and Shift B green color shown data.
- If Master sheet Column A to Column I is not same then (Yellow color) data will change as shown Blue color .Master Sheet Column J will sifted to each category Like shift A and Shift B blue color shown data. (shifted automatically Shift A data to Shift A and Shift B data to Shift B)
- I need constant reference is Column B data and split to Date wise.
- if same date and same machine will run same item then I need same row,if any thing is different then different row with data accordingly shift wise.
This kind of data i want to split in full month.
I hope this will help to you better understand.
Thanks in advance.god_karthi
-
Re: Short and split common multicolumn value
Try this:-
Nb:- Data from sheet "Master", results in sheet "Results" start "A4".
This code and its results are based on the results in sheet "After".( Latest )Code
Display MoreSub DataSort() Dim Dn As Range, txt As String, Rng As Range Dim Dic As Object, k As Variant, n As Long Dim p As Variant, c As Long Dim col1 As Integer, col2 As Integer, oSet As Long With Sheets("Master") Set Rng = .Range(.Range("A3"), .Range("A" & Rows.Count).End(xlUp)) End With ReDim ray(1 To Rng.Count, 1 To 57) Set Dic = CreateObject("Scripting.Dictionary") Dic.CompareMode = 1 For Each Dn In Rng With Application txt = Join(.Transpose(.Transpose(Dn.Resize(, 9))), ",") End With If Not Dic.exists(txt) Then Set Dic(txt) = CreateObject("Scripting.Dictionary") End If If Not Dic(txt).exists(Dn.Offset(, 9).Value) Then Dic(txt).Add (Dn.Offset(, 9).Value), Dn Else Set Dic(txt).Item(Dn.Offset(, 9).Value) = _ Union(Dic(txt).Item(Dn.Offset(, 9).Value), Dn) End If Next Dn For Each k In Dic.Keys c = c + 1 For Each p In Dic(k) oSet = 10 For n = 1 To 9 ray(c, n) = Dic(k).Item(p)(1, n) Next n For n = 11 To 34 col1 = IIf(p = "A", oSet, oSet + 1) ray(c, col1) = Dic(k).Item(p)(1, n) oSet = oSet + 2 Next n Next p Next k With Sheets("Results").Range("A4").Resize(c, 57) .Value = ray .Columns.AutoFit End With End Sub
-
Re: Short and split common multicolumn value
Dear Mr.MickG,
Amazing thanks for your valuable help you saved my lot of time and it works perfect what I need exactly.
once more I thanks for you with your brilliant work done for me. -
-
Re: Short and split common multicolumn value
You're welcome
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!