+ Reply to Thread
Results 1 to 14 of 14

VBA for may row data joint in one row

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-29-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    434

    VBA for may row data joint in one row

    Hello forum Experts & Guru’s
    We want a VBA for my following problem
    1. we have a a Detaild database of more then 8000 road record database in excel sheet (Sample Data type show in sheet 1 in enclosed file) in more then one row
    2. We want arrange this data base in one road data in single row.
    3. We also show what is database & what result I want
    4. we also want a process button in sheet 1 where we click then macro run

    Pls help

    Thanks in advance
    Santosh
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: VBA for may row data joint in one row

    differant approach

    Fill data in column A (with the macro below) and after that filter on total.

    See the attached file.

    Please reply.

    Sub filldata_acending_incolumnA_Oeldere()
    
    'from top to below (acending)
    
        Range(Range("a2"), Cells(Rows.Count, 3).End(xlUp).Offset(, -2)). _
            SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
        
    End Sub
    Attached Files Attached Files
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: VBA for may row data joint in one row

    Try the attached
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    01-29-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    434

    Re: VBA for may row data joint in one row

    Hello oeldere & jindon First thanks for your reply..

    oeldere sir... pls send 2003 xls file so that we look your approach ....

    jindon sir your provided file work as per my requirement but every time this create a new sheet....
    we want only one sheet where data copy i.e. sheet2

    pls also tell me about ur code working with comment so that we can easily understand..code..

    thanks both of u we also add reputation both of u..

  5. #5
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: VBA for may row data joint in one row

    See the excel 2003 version.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    01-29-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    434

    Re: VBA for may row data joint in one row

    Hello oeldere your provided macro & file not working as per my requiremtn.. u provided macro fill number in colum a then when we filter in total coloum then Road name & kms nos in one cell not resulted....


    Thanks for your trying

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: VBA for may row data joint in one row

    .............
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: VBA for may row data joint in one row

    NO it does not.

    But if you have read the text in #2 you would already have seen that.

    You could also had copied the given code in your excel 2003 file, instead of asking me to do it for you.

    I posted the code I used in #2.

  9. #9
    Forum Contributor
    Join Date
    01-29-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    434

    Re: VBA for may row data joint in one row

    sir we copy ur provided filldata_acending_incolumnA_Oeldere() in module 1 then we run this macro ...
    after run macro ..
    in sheet1 colum a value filldata as per macro.. then as per ur instruction we filter data on total..

    but sir when we filter data on total then

    We never see road name.. & kms nos....

    we only shee sr no. 1,2,3,4 in colum a colum B we see total on all filter row.. & sum of informt of total row..

    sir we want VBA to copy data from sheet 1 to sheet 2

    sr. road name & kms nos which is display in various row's in sheet1..

    Thanks for help but my problem is solved with jidon vba... but we r tying to understant that vba coding..

    we also asking for that with JINDON

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: VBA for may row data joint in one row

    Just a brief explanation.

    1) Store the data in an Array variable.
    2) Loop though row to find the unique Sr. No.
    3) Combine duplicates in same row concatenating col.3, and sum the rest of the columns.
    4) Output the result in Sheet2.

    Ask only where you don't understand, I don't want to explain from the basics.

  11. #11
    Forum Contributor
    Join Date
    01-29-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    434

    Re: VBA for may row data joint in one row

    Thank you so much.. for help to solve my problem

  12. #12
    Forum Contributor
    Join Date
    01-29-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    434

    Re: VBA for may row data joint in one row

    JINDON SIR if we want to run code with in a range then where we change pls suggest

    For example we want to run code from Row No 8 to 23

    pls suggest me..

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: VBA for may row data joint in one row

    Sub test()
        Dim a, i As Long, ii As Long, dic As Object
        Set dic = CreateObject("Scripting.Dictionary")
        a = Selection.Value
        For i = 1 To UBound(a, 1)
            If i > 1 Then
                If a(i, 1) = "" Then a(i, 1) = a(i - 1, 1)
            End If
            If a(i, 2) <> "TOTAL" Then
                If Not dic.exists(a(i, 1)) Then
                    dic(a(i, 1)) = dic.Count + 1
                    For ii = 1 To UBound(a, 2)
                        a(dic(a(i, 1)), ii) = a(i, ii)
                    Next
                Else
                    a(dic(a(i, 1)), 3) = _
                    a(dic(a(i, 1)), 3) & ", " & a(i, 3)
                    For ii = 4 To UBound(a, 2)
                        a(dic(a(i, 1)), ii) = a(dic(a(i, 1)), ii) + a(i, ii)
                    Next
                End If
            End If
        Next
        With Sheets("sheet2").Cells(1).Resize(dic.Count, UBound(a, 2))
            .CurrentRegion.Clear
            .Value = a
            .Borders.Weight = 2
            .Columns.AutoFit
            .Parent.Select
        End With
    End Sub

  14. #14
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: VBA for may row data joint in one row

    @santoh226001

    Your explaination in #9 is exactly what my macro does, so it won't fit all your requirements.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Joint data in columns with more the one condition
    By GIORGIO1985 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-20-2012, 06:32 PM
  2. How to set joint parameter for a few sheets?
    By markos17 in forum Excel General
    Replies: 0
    Last Post: 01-14-2011, 04:56 AM
  3. joint two columns
    By kumawat_s in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-23-2007, 03:26 AM
  4. [SOLVED] Joint Pivot Table
    By Tony in forum Excel General
    Replies: 1
    Last Post: 02-16-2006, 12:40 PM
  5. Joint two books
    By Jesús García in forum Excel General
    Replies: 1
    Last Post: 09-12-2005, 08:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1