PC Review


Reply
Thread Tools Rate Thread

Comparing cell to array

 
 
akissinger@comcast.net
Guest
Posts: n/a
 
      6th Sep 2007
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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing columns of text: cell value into array Myo_77 Microsoft Excel Misc 0 5th Dec 2007 11:56 AM
Comparing An Array in VBA Greg Microsoft Excel Misc 3 19th Jan 2006 06:31 PM
return array result in cell based on comparing dates Ruthki Microsoft Excel Worksheet Functions 7 30th Jun 2005 11:41 PM
Comparing ARRAY elements with RANGE data and created a 2nd array JimP Microsoft Excel Worksheet Functions 2 10th Mar 2004 07:29 PM
Comparing a value to an array Michael J. Malinsky Microsoft Excel Programming 3 15th Sep 2003 08:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:08 AM.