+ Reply to Thread
Results 1 to 5 of 5

need vba to fill values under particular header from master sheet

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-25-2015
    Location
    bangalore
    MS-Off Ver
    2019
    Posts
    120

    need vba to fill values under particular header from master sheet

    Dear expert

    I have some consolidation report i want fill data's in formatted table under respective column header's

    i have login code is 451414 like that 0062-451414-0-XM000-0000 in rawdata with amount i want split after hyphen of every value move to desire column header

    for e.g
    0062-451414-0-XM000-0000

    0062 to Company Code,[header]
    451414 to Account,[header]
    (if value is 0) change it 6 digit 00000 to Cost Center,[header]
    XM000 to Sub-Account,[header]
    0000 to Intercompany.[header]

    towards 451414 amount is in D column move to credit amount[header]

    please find the attachment
    Attached Files Attached Files
    Last edited by julielara; 02-25-2016 at 04:25 PM. Reason: att

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

    Re: need vba to fill values under particular header from master sheet

    Try
    Sub test()
        Dim a, i As Long, n As Long, x()
        With Sheets("master")
            a = Intersect(.Columns("a:d"), .UsedRange).Value
        End With
        With CreateObject("VBScript.RegExp")
            .Pattern = "([A-Z\d]{4})-(451414)-(0|\d{6})-([^-]+)-([^-]{4})$"
            For i = 2 To UBound(a, 1)
                If .test(a(i, 1)) Then
                    n = n + 1: ReDim Preserve x(1 To n)
                    x(n) = Split(.Replace(a(i, 1), "$1^" & Format$(.Replace(a(i, 1), "$3"), "0000") & _
                        "^$2^$4^$5^00000000^000^MAY-15^USD^AMOUNT^" & a(i, 4) & "^NO"), "^")
                End If
            Next
        End With
        With Sheets("BeforeAdjustment")
            .Rows("11:" & Rows.Count).ClearContents
            If n > 0 Then
                With .[e11].Resize(n, 12)
                    .Columns(1).NumberFormat = "@"
                    .Value = Application.Index(x, 0, 0)
                End With
            End If
        End With
    End Sub
    Attached Files Attached Files

  3. #3
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: need vba to fill values under particular header from master sheet

    Maybe :

    Sub Test()
      For Each cell In Sheets("Master").Range("A2:A20")
          If InStr(cell, "-451414-") Then Sheets("After run macro Adjustment").Cells(65000, "E").End(xlUp).Offset(1).Resize(, 12) = Application.Index(Split(Join(Array(Replace$(Replace$(cell, "-0-", "-000000-"), "-", "|"), "00000000", "000", "MAY-15", "USD", "AMOUNT", cell.Offset(, 3), "NO"), "|"), "|"), Array(1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12))
      Next cell
    End Sub

  4. #4
    Forum Contributor
    Join Date
    11-25-2015
    Location
    bangalore
    MS-Off Ver
    2019
    Posts
    120

    Re: need vba to fill values under particular header from master sheet

    Amazing Experts !!!!Perfect Code thanks alot

  5. #5
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: need vba to fill values under particular header from master sheet

    You are welcome, glad to help.


    Regards

+ 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. Replies: 1
    Last Post: 09-15-2014, 01:03 PM
  2. Replies: 3
    Last Post: 09-17-2013, 12:57 PM
  3. vba UPDATES VALUES THROGUH COLUMN VALUES TO MASTER SHEET FROM CLOSED WORKBOOK
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-05-2013, 09:47 PM
  4. [SOLVED] Auto Fill Secondary Sheets from Master Sheet based on values in a colum
    By hfcamper in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2013, 09:04 AM
  5. Create a master sheet to auto fill many documents.
    By citadel-maritime in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-26-2013, 02:19 AM
  6. Replies: 8
    Last Post: 12-04-2010, 01:20 PM
  7. Replies: 3
    Last Post: 05-27-2010, 10:57 AM

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