Results 1 to 4 of 4

How to Manipulate data like a pivot table using a Macro that allow for data to be changed

Threaded View

  1. #1
    Registered User
    Join Date
    06-13-2012
    Location
    Texas, US
    MS-Off Ver
    Excel 2010
    Posts
    5

    Question How to Manipulate data like a pivot table using a Macro that allow for data to be changed

    Practice123.xlsm

    I have a lot to learn about VBA but was looking for advice to help steer me in the right direction with the current project I am working on.

    I have a Intermediate Step Data sheet that has data organized by a Code Number (row) and a Date (column).

    I wrote a sub procedure that loops through all the Code Numbers and sums the values associated with alike Code Numbers on the first date.


    Option Explicit
    Option Base 1
    
    Sub IntermR_Loop()
    
        Dim Counter As Integer
        Dim Counter2 As Integer
        Dim CostCodeAcct(69, 2) As Variant
        Dim AcctCode As Variant
        Dim SumofAcct As Double
        
        'Get Cart of Account Codes
        For Counter = 1 To 69
            CostCodeAcct(Counter, 1) = Application.Worksheets("Cost Codes").Cells(3 + Counter, 7)
        Next
        
            For Counter = 1 To 69
                AcctCode = CostCodeAcct(Counter, 1)
                Counter2 = 1
                SumofAcct = 0
                Do While Application.Worksheets("Interm").Cells(2 + Counter2, 1) <> ""
                    If Application.Worksheets("interm").Cells(2 + Counter2, 1) = AcctCode Then
                        SumofAcct = SumofAcct + Application.Worksheets("interm").Cells(2 + Counter2, 2)
                        'MsgBox (SumofAcct)
                    End If
                Counter2 = Counter2 + 1
                Loop
                'MsgBox (AcctCode & SumofAcct)
            CostCodeAcct(Counter, 2) = SumofAcct
            
               
            Next
        
        End Sub
    I don't think I can use it for what I am really trying to do though.

    What I need to do is take all the alike code number's values for each date and sum them and store the value in a separate sheet showing the Code Number's Sum associated with that date.

    I think i need to write a procedure similar to the one shown above only utilized a 3D array. I have been reading posts and reading through John Walkenbach's Excel 2010 Power Programming with VBA, and really just feel frustrated to have zero progress in two weeks....

    Any help would be appreciated. Thanks

    Sorry if i didnt explain myself well. I will be happy to try and clear up confusion.
    Last edited by TryingTolearnVBA171; 06-13-2012 at 03:14 AM. Reason: Moderater

Thread Information

Users Browsing this Thread

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

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