Object required error- looping through array- noobie

sickel2

New Member
Joined
Oct 11, 2011
Messages
2
I'm getting an object required error and I think it's coming from the for loop.


I'm trying to make an array out of the values of the cells in a range and then print them to make sure that I did it correctly.

Many thanks for any help. Should be a softy.


Sub lookthrough()

Dim georange As Range
Dim geos As Variant


Range("B8").Select
Set georange = Range(Selection, Selection.End(xlToRight)).Select

Set geos = georange.Value

For i = 1 To UBound(geos)
MsgBox geos(i, 1)
Next


End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try this:
Code:
Sub lookthrough()

    Dim i, intLastRow As Integer
 
    With ActiveWorksheet

        intLastRow = .Range("A65535").End(xlUp).Row
    
        For i = 1 To intLastRow
            MsgBox .Cells(i, 1)
        Next i

    End With

End Sub

That will look for the last row in Column A, and for each item from A1 to A's last row will message you the value of whatever is in the cell.

The old code was looking for the rightmost cell from B8, and then messaging you the rows from A1 to A of the column number of the rightmost cell from B8.

What exactly are you trying to do?
 
Upvote 0
Thank you for looking at my post.

B8 contains the first cell whose value I want in an array. The rest of the cells are in row 8 so I am trying to go from B8 to the right to grab the values.

I need to create an array so that I can check it against another list.

Let me know if you have any ideas for changing the syntax or object types.

Thanks again.

-Rob
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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