Index Data

Utsav

Board Regular
Joined
Jun 1, 2006
Messages
170
Hi Dear,

I have a list of I say about 50 sheets ,
In all my sheets G4 contains "Cust id " and C7& C8 contains name and address respectively.

would like to know Can some how I get, Cust Id, Name and address in a single sheet without copying or pasting.
Like

Cust Id Name add

thanx in advance. !

Regards,
Utsav
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Code:
Sub FF()

    Dim i As Integer, sh As Worksheet
    Dim arr1() As Variant, arr2() As Variant, arr3() As Variant
    
    For i = 1 To 50
        With Worksheets(i)
            ReDim Preserve arr1(1 To i)
            ReDim Preserve arr2(1 To i)
            ReDim Preserve arr3(1 To i)
            arr1(i) = .Range("G4")
            arr2(i) = .Range("C7")
            arr3(i) = .Range("C8")
        End With
    Next
    
    Set sh = Sheets.Add
    sh.Name = "Total"
    With sh
        .Range("A1:C1") = Array("Cust Id", "Name", "Address")
        .Range("A2").Resize(UBound(arr1, 1)) = arr1
        .Range("B2").Resize(UBound(arr2, 1)) = arr2
        .Range("C2").Resize(UBound(arr3, 1)) = arr3
    End With
    
End Sub
 
Upvote 0
I see you write "about 50 sheets". As you see I use hard-coded value of 50 in loop. Please, adjust it to real amount of sheets u gonna process.
 
Upvote 0
it is showing all the details of first sheet(means 42 row line items for 1 sheet)
no data for other 41 sheets
 
Upvote 0
Change this line:

Code:
    Dim arr1() As Variant, arr2() As Variant, arr3() As Variant
 
Last edited:
Upvote 0
Code:
Sub FF()

    Dim i As Integer, sh As Worksheet
    Dim arr1() As Variant, arr2() As Variant, arr3() As Variant
    
    For i = 1 To 50
        With Worksheets(i)
            ReDim Preserve arr1(1 To i)
            ReDim Preserve arr2(1 To i)
            ReDim Preserve arr3(1 To i)
            arr1(i) = .Range("G4")
            arr2(i) = .Range("C7")
            arr3(i) = .Range("C8")
        End With
    Next
    
    Set sh = Sheets.Add
    sh.Name = "Total"
    With sh
        .Range("A1:C1") = Array("Cust Id", "Name", "Address")
        .Range("A2").Resize(UBound(arr1, 1)) = WorksheetFunction.Transpose(arr1)
        .Range("B2").Resize(UBound(arr2, 1)) = WorksheetFunction.Transpose(arr2)
        .Range("C2").Resize(UBound(arr3, 1)) = WorksheetFunction.Transpose(arr3)
    End With
    
End Sub
 
Upvote 0
Can u insert some function that it automatically recall the number of sheets in the workbook.
so that the manual intervention of counting the sheets can be avoided.


Regards,
Utsav
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,894
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top