Jump to content

Recommended Posts

Posted

Bom dia,

Necessito de ajuda. :wallbash:

Tenho uma tabela que tem três colunas (A-Nome, B-Valor e C-Cont)

A coluna Cont, identifica o nº de valores que cada utilizador tem (existe utilizadores que não têm valores).

A minha dificuldade é inserir linhas, abaixo do contador.

Exemplo:

O Rui tem um valor 12 e tem 3 contagens, então deveria inserir duas linhas abaixo (com o mesmo conteudo da seleccionada).

Nome     Valor Cont

Luis       12

Rui12 3

Teresa    18

Manuel    18 1

Rita       12

Vasco      12

Posted

Não entendi muito bem...

Se tens isto:

Luis  |12|

Rui  |12|3

teresa|18|

Queres que fique assim ?

Luis  |12|

Rui  |12|3

Rui  |12|3

Rui  |12|3

teresa|18|

ou seja o count é para repetir as linhas ?

Posted

Estranho ... pensava que tinha respondido!

O que já tens feito ? Basicamente é um ciclo até encontrar um valor na coluna C. Ao encontrar, copia o número de linhas de acordo com o valor que está na coluna.

  • 1 month later...
Posted

Consegui encontrar o que queria B), mas gostava de saber se posso copiar o conteúdo das células?

Junto envio o código que utilizei:

Private Sub CommandButton1_Click()

    Dim FirstRow As Long
    Dim LastRow As Long
    Dim iRow As Long
    Dim wks As Worksheet

    Set wks = ActiveSheet

    With wks
        FirstRow = 2
        LastRow = .Cells(.Rows.Count, "D").End(xlUp).Row

        For iRow = LastRow To FirstRow Step -1
            With .Cells(iRow, "D")
                If IsNumeric(.Value) Then
                    If .Value > 1 Then
                        .Offset(1, 0).Resize(.Value).EntireRow.Insert
                    End If
                End If
            End With
        Next iRow
    End With

End Sub

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.