VBA Zoeken binnen een range

Pagina: 1
Acties:

Onderwerpen

Vraag


  • vandenbrinkw
  • Registratie: September 2017
  • Laatst online: 19-06-2021
Sub generateRandomNumbers()

'generate the random nubers
Dim x As Integer


For x = 1 To Cells(3, 7)


Cells(x, 1) = Application.WorksheetFunction.Randbetween(Cells(2, 7), Cells(1, 7))

Next x


End Sub

Sub Delete_Column_A()


Columns("A:A").Select
Selection.ClearContents
End Sub


Sub CheckIfPresent() 'werkt niet

If range(Cells(1, 1), Cells(100, 1)) = Cells(5, 7) Then

MsgBox ("Yes")

Else: MsgBox ("No")

End If

End Sub


Mijn sub checkifpresent werkt niet. Ik heb al geprobeert om derange te versimpelen tot 1 cel. Dan werkt het ook niet.

Max 100
Min 0
Amount 10

Present? 73 (bijvoorbeeld)


100=g1
0=g2
10=g3
73=g5

de lijst met random nummers staat in kolom A van A1 tot A(amount)

Alle reacties


  • Boeryepes
  • Registratie: Januari 2016
  • Niet online
Daar is de range.find functie voor.

Even googlen ... Bijvoorbeeld voorbeeld https://excelmacromastery.com/excel-vba-find/

Die kun je dan wrappen in je Checkifexists functie

[ Voor 16% gewijzigd door Boeryepes op 30-09-2017 19:50 ]

The biggest communication problem is we do not listen to understand. We listen to reply.