Help in Procv Copy Data

Asked

Viewed 110 times

0

I have a database where an employee has three dependents or more, when I do a PROCV to pull one dependent at a time, only the first and the last appear.

How do I select the first in one column the second in another column and so on?

EXAMPLE

I have in the database these figures:

216 WILLIAN Son BRUNO

216 WILLIAN Son LUIS

216 WILLIAN Son YASMIN

I made a PROCV in another spreadsheet to leave a father and in other columns the children, I managed to pull through the PROCV the first son and to the last. But I can’t pull the middle child.

216 WILLIAN Son BRUNO Son YASMIN

I also made a code that I believe is correct in logic, but I can’t make it copy data from one folder to another...

Sub limpar()

Dim num As Integer
Dim contChave, contPrincipal As Integer
Dim numDependente As Integer
Dim idAtual As Integer

contPrincipal = 2
contChave = 2
Sheets("Chave").Select
Cells(contChave, 2).Select
Do While ActiveCell.Value <> ""
    num = ActiveCell.Value
    numDependente = 0
    Sheets("SÓCIOS COOP").Select
    idAtual = Cells(contPrincipal, 3).Value
    
    Do While num = idAtual
        numDependente = numDependente + 1
        Set depAtual = Range(Cells(contPrincipal, 6), Cells(contPrincipal, 8))
        Sheets("Chave").Select
        Set depend = Range(Cells(contChave, (1 + numDependentes * 3)), Cells(contChave, (1 + numDependentes * 3 + 2)))
    
        depAtual.Copy depend
        contPrincipal = contPrincipal + 1
        Sheets("SÓCIOS COOP").Select
        Cells(contPrincipal, 3).Select
        idAtual = ActiveCell.Value
        
    Loop
    contChave = contChave + 1
    Sheets("Chave").Select
    Cells(contChave, 2).Select
    
Loop








End Sub

  • It is duplicate of this but the site does not allow signaling:Help in Procv to select data

  • ok give up.....

  • It’s not your link question?

  • Yes, but it’s not wrong?

  • No, if you already asked the question, you didn’t have to duplicate it. I saw that you created another account and you won’t be able to edit the other one. I suggest you create a fixed account and request merge (join) of the accounts via this link: https://answall.com/contact

1 answer

0

Well come on, I think you need to set a variable to save, try this:

Set depend = Range(Cells(contChave, (1 + numDependentes * 3)), Cells(contChave, (1 + numDependentes * 3 + 2))).Copy

Browser other questions tagged

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