Cell selection

Asked

Viewed 139 times

2

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

Someone can help me?

This is the code I have for selecting the combobox1 cell:

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 an image 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 precorre all the lines where you find the product of combobox1.

I’ve already reached the solution, thank you.

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

  • Do I ask difficult questions, is that I do not ask the questions in a correct way or is it because I ask the questions that hardly anyone answers or helps me. I still can’t figure out where the problem is.

  • First of all, Bruno, it takes patience! Remember that the site is community, sometimes users who understand the theme of your question are not online or have not seen your question yet. The tip I give you is always follow the guidelines of [Ask] and try to be succinct and objective in doubt, trying to focus only on the problem.

  • Good evening, I have seen that I am not playing a good role in the forum, but I have only been using it for 2 or 3 days and I am not being understood by the community. In life it’s easy to tear someone down, to make the difference backwards is that it’s harder and harder. What I mean is that as I am new in the forum where I needed the help of the community, what is happening is the opposite, is the community judge me and do not help......that anyone does the opposite is that it is difficult unfortunately...but thank you all anyway.

  • @Bruno did not understand what you meant by "I am not being understood by the community", you speak of the question? She needs to be clearer, if you can isolate the problem in one minimal example already helps a lot. At what point is the community judging you too? On the contrary, diegofm is helping.

  • Thanks for helping me, so do you think my question is clearer or do I need to get better? You know these are my first steps in the forum and I want to be welcomed by the community

  • What do I need to improve on the question? I really need help on this issue with some urgency.......

  • Can I just ask why you didn’t get help from anyone in the community? I’m going to put some options: 1- Couldn’t I put my question clearly? 2- It was a difficult problem to solve and the community couldn’t help? 3- Another reason. I only ask this to know where I have

Show 2 more comments

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

Note: change the name of Cb_dated by the name of your outgoing date combobox.

Note: I assumed that the name of your combobox1 is Cb_tipofralda, if it is not replaced by the corresponding name.

Obs3: We all work and have several things to do, it is not always that we can stop life and come to the topics and answer. So patience is key.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.