- 08 Mar 2019 às 17:56
#41822
Ola Pessoal, estou com um erro que não consigo resolver.
Tenho uma lista drop down (nomes) que vem de uma lista dinâmica de outra folha.
Esta lista dinamica tem um nome e é criada a partir de um filtro avancado e ordenada alfabeticamente.
Ate aqui tudo bem a lista funciona na segunda tabela.
Mas quero associar o comando procurar "Find" para procurar nessa lista dinamica o "nome"
Caso encontre ele ja fica registado.
caso o nome nao esteja na lista ele adiciona a lista..
Segue em anexo um bocado do código vba:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Dim RequestRng, FoundRequest As Range
Dim Resp As Integer
Dim ItemRow, ItemCol, FirstAvailRow As Long
If Not Intersect(Target, Range("D4:S4")) Is Nothing And Range("B4").Value = False And Range("B5").Value = False Then
ItemRow = Range("B3").Value
ItemCol = Cells(11, Target.Column).Value
Cells(ItemRow, ItemCol).Value = Target.Value
End If
FirstAvailRow = Folha4.Range("F9999").End(xlUp).Row + 1 'Primeira linha disponivel
If Not Intersect(Target, Folha9.Range("I4")) Is Nothing And Folha9.Range("B5").Value = False Then
If Target.Value <> Empty Then
On Error Resume Next 'Previne erro quando nao encontra a lista Request
Set RequestRng = Folha4.Range("Request")
Set FoundRequest = RequestList.Find(What:=Target.Value, LookAt:=xlWhole, LookIn:=xlValues)
If FoundRequest Is Nothing _
Then Resp = MsgBox(Target.Value & " Is Not Currently a Request." & vbCrLf & "Would you like to add it now?", vbYesNo, "Request Not Found")
If Resp = vbYes Then Folha4.Range("F" & FirstAvailRow).Value = Target.Value
End If
GetRequest
End If
End Sub
Não consigo saber se o foundrequest não esta na lista Dropdown
Na tabela 9 ao mudar para um dos elementos da lista ele muda.
mas se escrevo um que nao esteja na lista da o seguinte erro:
Este valor não corresponde às restrições de validação de dados definidas para esta célula.
Tenho uma lista drop down (nomes) que vem de uma lista dinâmica de outra folha.
Esta lista dinamica tem um nome e é criada a partir de um filtro avancado e ordenada alfabeticamente.
Ate aqui tudo bem a lista funciona na segunda tabela.
Mas quero associar o comando procurar "Find" para procurar nessa lista dinamica o "nome"
Caso encontre ele ja fica registado.
caso o nome nao esteja na lista ele adiciona a lista..
Segue em anexo um bocado do código vba:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Dim RequestRng, FoundRequest As Range
Dim Resp As Integer
Dim ItemRow, ItemCol, FirstAvailRow As Long
If Not Intersect(Target, Range("D4:S4")) Is Nothing And Range("B4").Value = False And Range("B5").Value = False Then
ItemRow = Range("B3").Value
ItemCol = Cells(11, Target.Column).Value
Cells(ItemRow, ItemCol).Value = Target.Value
End If
FirstAvailRow = Folha4.Range("F9999").End(xlUp).Row + 1 'Primeira linha disponivel
If Not Intersect(Target, Folha9.Range("I4")) Is Nothing And Folha9.Range("B5").Value = False Then
If Target.Value <> Empty Then
On Error Resume Next 'Previne erro quando nao encontra a lista Request
Set RequestRng = Folha4.Range("Request")
Set FoundRequest = RequestList.Find(What:=Target.Value, LookAt:=xlWhole, LookIn:=xlValues)
If FoundRequest Is Nothing _
Then Resp = MsgBox(Target.Value & " Is Not Currently a Request." & vbCrLf & "Would you like to add it now?", vbYesNo, "Request Not Found")
If Resp = vbYes Then Folha4.Range("F" & FirstAvailRow).Value = Target.Value
End If
GetRequest
End If
End Sub
Não consigo saber se o foundrequest não esta na lista Dropdown
Na tabela 9 ao mudar para um dos elementos da lista ele muda.
mas se escrevo um que nao esteja na lista da o seguinte erro:
Este valor não corresponde às restrições de validação de dados definidas para esta célula.