Finding in a Range and Looping through variables

mribadeneira

New Member
Joined
Apr 10, 2013
Messages
7
I am having problems getting my program to work.
First, I cant get the FindMe function to work, i get the error Object doesn't support this property or method. I am not really sure whats wrong.
My second problem is I have variables NB1 through NB8 defined in the main Sub and I want this program to loop using all of them in turn. However I get the error that the variable NBi is not defined. How can i set the code up so that by using a statement like
Code:
 For i = 1 To 8
it runs thorugh all the NB variables?

My code is below to see if you can spot any mistakes. Any help is greatly appreciated!
smile.gif


Code:
Private Sub CollectDataOp1()
Dim i As Integer
Sheets("Datos").Select
Range("A1").Select
With Worksheets("Datos").Range(Selection, Selection.End(xlDown))
    Set c = .FindMe.fecha.Value , LookIn:=xlValuese
    If Not c Is Nothing Then
        firstaddress = c.Address
        Do
            For i = 1 To 8
                If c.Offset(0, 2).Value = NBi & " " & r1 Then
                    If opcion1.TEA.Value = True Then
                        BP1 = c.Offset(0, 4)
                        Sheets("Resultados").Select
                        Range("A3").Select
                        Range(Selection.End(xlToRight)).Offset(0, 1) = BP1
                        Sheets("Datos").Select
                    End If
                    If opcion1.Participacion.Value = True Then
                        BP1 = c.Offset(0, 5)
                        Sheets("Resultados").Select
                        Range("A3").Select
                        Range(Selection.End(xlToRight)).Offset(0, 1) = BP1
                        Sheets("Datos").Select
                    End If
                    If opcion1.Monto.Value = True Then
                        BP1 = c.Offset(0, 6)
                        Sheets("Resultados").Select
                        Range("A3").Select
                        Range(Selection.End(xlToRight)).Offset(0, 1) = BP1
                        Sheets("Datos").Select
                    End If
                End If
            Next i
        Loop While Not c Is Nothing And c.Address <> firstaddress
    End If
End With

End Sub

TEA, Participacion, and Monto are select boxes in a Userform.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,215,360
Messages
6,124,492
Members
449,166
Latest member
hokjock

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