+ Reply to Thread
Results 1 to 5 of 5

Thread: Need help with a code to add some more information.

  1. #1
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    113

    Post Need help with a code to add some more information.

    Hi I have a code which is given and working fine. Using that code I am getting only 50% information which is required. Please help me editing that script in a way which will give me the output the way I want.
    In page 1 the data is in different rows and columns and I have 20 pages like that. I have the data in different rows and columns from page2 to page20. (All the data will be in same rows and columns for all these sheets except page 1). One more thing the below code is only gathering the data for only the below queue name and if there exists another queue name it is not giving the output for the second queue name. So I need is For a name specified if there are 2 queues also i need that information also to be in my output. The same way I need the output from the remaining pages (2,3,4....) to be in the same page. I mean I need finally all the data to be in a single sheet.

    The data for a name in page 1 some times will be in page 2 or the same way in the next page also.

    I may not be clear to you. So, please have a look at the pages first and also run the macro which is given below to understand first what I am trying to say and help me. I need the output in the same format the one which you will get after running the macro given below. Please some one save me...

    Sub Gather_Data()
        Dim vD          As Variant
        Dim x           As Long
        Dim y           As Long
        Dim z           As Long
    
        'COLLECT DATA
        With Worksheets("Sheet1")
            vD = Intersect(.Columns("F:F"), .UsedRange)
            ReDim Preserve vD(1 To UBound(vD), 1 To 4)
    
            For x = 1 To UBound(vD)
                If Not IsEmpty(vD(x, 1)) Then
                    vD(x, 2) = .Cells(x + 1, 3)
                    If .Cells(x + 3, 3) = "Total" Then
                        vD(x, 3) = .Cells(x + 3, 11)
                        vD(x, 4) = .Cells(x + 3, 45)
                    Else
                        vD(x, 3) = .Cells(x + 1, 10)
                        vD(x, 4) = .Cells(x + 1, 45)
                    End If
                End If
            Next x
        End With
    
        'POST DATA
        With Worksheets("Sheet2")
            z = .Cells(.Cells.Rows.Count, 1).End(xlUp).Row + 1
            For x = 1 To UBound(vD)
                If Not IsEmpty(vD(x, 1)) Then
                    For y = 1 To 4
                        .Cells(z, y) = vD(x, y)
                    Next y
                    z = z + 1
                End If
            Next x
        End With
    End Sub
    Attached Files Attached Files

  2. #2
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,399

    Re: Need help with a code to add some more information.

    It will be good if you attach a sample of the macro output so we can see and understand what your requirement is.
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    113

    Re: Need help with a code to add some more information.

    I have given the macro above. That is the macro which i am using now.

  4. #4
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,399

    Re: Need help with a code to add some more information.

    No no, attach the output obtained from the macro.
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  5. #5
    Valued Forum Contributor MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    5,300

    Re: Need help with a code to add some more information.

    Hi kishoremcp,

    It seems you need to cycle through all your worksheets and add the data to the Data sheet. I think you need to use the Worksheet Index notation to do this is VBA. Worksheets.Count will be the number of worksheets and Worksheets(Index) will go from left to right across them.

    Something like this code below

    Dim ShtCtr as double
    For ShtCtr = 2 to Worksheets.Count
    With Worksheets(ShtCtr) 
    'do some code in here to gather your sheet data
    End With
    Next ShtCtr
    One test is worth a thousand opinions.
    Click the * below to say thanks.

+ Reply to Thread

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.2.0