Jeg har problemer med at få denne kode til at virke. Det skal være sådan, at når man indtaster en værdi i kolonnen P, skal der søges i arket "Gl. ordning", kolonne E og tjekke om værdien findes. Hvis den gør, skal der komme en besked. Der skal ikke ske noget hvis værdien ikke findes.
Arkets kode: Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("P:P")) Is Nothing Then Call find_ma_nr End If End Sub
Modul1: Sub find_ma_nr() Dim FindString As String Dim Rng As Range If Trim(FindString) <> "" Then With Sheets("Gl. ordning").Range("E:E") Set Rng = .Find(What:=FindString, _ After:=.Cells(.Cells.Count), _ LookIn:=xlValues, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) If Not Rng Is Nothing Then MsgBox "værdi fundet" Else End If End With End If End Sub
Arkets kode: Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("P:P")) Is Nothing Then Call find_ma_nr Target.Cells(1,1) End If End Sub
Modul1: Sub find_ma_nr(ledEfter as string) Dim FindString As String Dim Rng As Range FindString = ledEfter If Trim(FindString) <> "" Then With Sheets("Gl. ordning").Range("E:E") Set Rng = .Find(What:=FindString, _ After:=.Cells(.Cells.Count), _ LookIn:=xlValues, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) If Not Rng Is Nothing Then MsgBox "værdi fundet" Else End If End With End If End Sub
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.