searching through an array without looping through it.

jakeb3482

Board Regular
Joined
Mar 6, 2006
Messages
74
ok so i need to look through an array to see if a value is in there. i dont think i can loop through the array though with the current structure of the code. is there anyway to see if a string is in an array without looping through it? here is my current code:

device_array is the array i need to search through in the ElseIf statements.

Code:
For y = 1 To last_row
    For x = 1 To last_col
        
        
        If Workbooks(device_map).Sheets("sheet1").Cells(y, x) = "0" Then
           Workbooks(device_map).Sheets("sheet1").Cells(y, x) = ""
           Workbooks(device_map).Sheets("sheet2").Cells(y, x) = ""
        
        ElseIf Workbooks(device_map).Sheets("sheet1").Cells(y, x) = device_array(z) Then
            'find coordinate
            coordinate = (x - 1) & (y - 1)
            'find start of column coordinate
            coord_col = find_in_col((x - 1), 5)
            'use start of column coordinate to find row coordinate
            coord_row = find_in_col_start((y - 1), 6, coord_col)
            'find 1kHz value in csv file and put into sheet 1 of map
            Workbooks(device_map).Sheets("sheet1").Cells(y, x) = Cells(coord_row, "L")
            'find 2600Hz value in csv file and put into sheet 2 of map
            Workbooks(device_map).Sheets("sheet2").Cells(y, x) = Cells(coord_row, "Z")

        ElseIf Workbooks(device_map).Sheets("sheet1").Cells(y, x) <> "" And Workbooks(device_map).Sheets("sheet1").Cells(y, x) <> device_array(z) And Workbooks(device_map).Sheets("sheet1").Cells(y, x) <> "X" Then
                'if die wasnt tested put an x
                Workbooks(device_map).Sheets("sheet1").Cells(y, x) = "Z"
                Workbooks(device_map).Sheets("sheet2").Cells(y, x) = "Z"
                
        End If
        
        
    Next x
Next y
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
but how do i put the range of the array in the match function? the match function wants a column range, not an array range...
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,245
Members
448,555
Latest member
RobertJones1986

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