Cell selection

2

I need to select the line with the value of combobox 1 and the date of combobox 3 to select the desired line to delete. This is the problem I have to solve.

Can someone help me?

This is the code I have to select the cell of combobox1:

Private Sub RemverRegisto_Click()
Range("E3").Select

While ActiveCell <> ""
If CB_TipoFralda.Text = ActiveCell Then
Resposta = MsgBox("Registo encontrado, deseja excluir?", vbYesNo)
End If
If Resposta = vbYes Then
ActiveCell.EntireRow.Delete
Exit Sub
End If
ActiveCell.Offset(1, 0).Activate
Wend
Exit Sub
End Sub

I'll put a picture to show what I want:

I want to activate the line with the values of the product combobox and the date to delete and with the above code only active the line with the value of the product combobox, then preclear all the lines in which find the product of combobox1. >

I've got the solution, thank you.

If you need to see the solution just ask me to put it here

    
asked by anonymous 25.05.2017 / 17:04

1 answer

0

Good afternoon, I think your code should look like this below:

Private Sub RemverRegisto_Click()
'declaração de variáveis
    dim linha as long
    dim flag as boolean
'iniciação das variáveis
    linha=3
    flag=false
'inicia o procedimento
    do
        if cells(linha,5).value = CB_TipoFralda.Text and cells(linha,3).value = CB_DataSaida.Text then
            flag=true
            Resposta = MsgBox("Registo encontrado, deseja excluir?", vbYesNo)
            If Resposta = vbYes Then
                ActiveCell.EntireRow.Delete
                exit sub
            else
                exit sub
            end if
        else
            linha=linha+1
        end if
    loop until cells(linha,5).value="" or flag=true
end sub

Obs1: Change the name of CB_DataSaida to the name of your output date combobox.

Obs2: I assumed that the name of your combobox1 is CB_TypeFair, if not replace with the corresponding name.

Obs3: We all work and we have several things to do, it is not always possible to stop life and come to topics and respond. So having patience is critical.

    
27.04.2018 / 20:33