Comparing cell to array

A

akissinger

For some reason i have put a name of a sheet in an array and i am
trying to compare the array to a cell value that has the same name.
It will come back with and error that indicates that no cells mach any
name in the array. When i debug. print and use the immediate box to
see what values are in both places they are the same. Help


Sub sheetray()
Dim b As Long
b = 2
Do While Cells(1, b).Value <> ""
If Len(Cells(1, b).Value) > 9 Then
b = b + 1
Else
Cells(1, b).Value = Cells(1, b).Value + ".accum"
b = b + 1
End If
Loop

Dim SNarray, i
Dim table(1 To 100, 1 To 3) As Variant
Dim j As Long
Dim z As Long
ReDim SNarray(1 To Sheets.Count)
Dim name As String
Dim arch As String

For i = 1 To Sheets.Count
SNarray(i) = ThisWorkbook.Sheets(i).name
Debug.Print SNarray(i)
Next
Dim x As Long

For j = 2 To Sheets.Count
Sheets(SNarray(j)).Select
table(j, 1) = Cells(2, 7).Value
table(j, 2) = Cells(2, 9).Value
Sheets("Sheet1").Select
x = 2

Do While SNarray(j) <> Cells(1, x).Value
x = x + 1
Loop
Cells(2, x).Value = table(j, 1)
Cells(3, x).Value = table(j, 2)
Debug.Print table(j, 1)
Debug.Print table(j, 2)
Next j

Sheets(SNarray(2)).Select
end sub

The cells b2 - b50 are formated to be CAE130001+ incrementing to 50.
The sheets are named Sheet1 and CAE130017.accum, CAE130022.accum and a
couple more in the column with a sheet name that is equal to the name
in the cell the probram retreves a value from the sheet with the
corisponding value and puts in into sheet one in a designated
location. This only gets values at SHeet name = Cells name . Please
help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top