VBA to Compile List from Multile Sheets.

CreativeUsername

Board Regular
Joined
Mar 11, 2017
Messages
52
Hi,

I'm stumped with the following problem.

I have a software output that is exported to Excel in a matrix with combined text and numbers. There are merged cells left right and center BUT I prefer NOT to unmerge them if possible for ease of visual analysis later. Several tabs each containing a unique matrix.

I have the following code that works fine on the output to cycle through the tabs and get a specific value from a specific location and create a list. Some how its backfiring and grabbing erroneous values. Partially because of the variable location of the actual data but in some cases the printed results make no sense.

My original code grabs a 16 digit number from a specific cell and works.
Code:
Dim ws As Worksheet
     
    Application.ScreenUpdating = False
    Sheets("Accts").Activate
     
    For Each ws In Worksheets
        If ws.Name <> "Accts" Then
            ws.Range("E9").Copy
            ActiveSheet.Paste Range("A65536").End(xlUp).Offset(1, 0)
        End If
    Next ws
     
    Application.ScreenUpdating = True
END Sub [code]

In the new output I receive the number I'm looking for will be in column B between values 5 and 20 (actually less than that range but it shouldn't matter).

After I get this section working there are other column ranges I need to search and return values in the offset 3 right location... 
My code looks like this:

[code]Sub Compile()
Dim ws As Worksheet
     
    Application.ScreenUpdating = False
    Sheets("Trends").Activate
     
    For Each ws In Worksheets
        If ws.Name <> "Trends" Or ws.Name <> "All 2011" Then '<- skip these tabs
        
        ws.Range("B8:B15").Find "ACCT NUM:", LookIn:=xlValues '<- find ACCT NUM Cell in that range
        ActiveCell.Offset(0, 3).Copy '<-- move over 3 cells and copy cell
            
            ActiveSheet.Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues '<- paste value only at bottom of list.
            
            End If
    Next ws
    
Application.ScreenUpdating = True
End Sub [code]
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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