2 Dados x e y como parâmetros range, retorne z=|x1y1|+|x2y2|+…+|xn.yn|
Criar função Prod Abs (x as range, y as range) as long
3Desenhe uma janela para entrar nome, sobrenome e pronome de tratamento (sr, Sra, Srta) e registre em uma planilha o nome completo mais pronome de tratamento (coluna A) e Data de registro (coluna B)
4 Crie uma macro que elimina valores repetidos em um range fornecido como parâmetro (vetor) (dica: use gravador de macro e entenda a função dados-> remover duplicatas)
respostas:
2: Function ProdAbs(x As Range, y As Range) As Long
Dim CounterX As Long
Dim CounterY As Long
CounterX = 0
CounterY = 0
ProdAbs = 0
For Each xn In x.Cells
CounterX = CounterX + 1
CounterY = 0
For Each yn In y.Cells
CounterY = CounterY + 1
If CounterX = CounterY Then
ProdAbs = ProdAbs + Abs(xn.Value * yn.Value)
End If
Next
Next
End Function
3:Private Sub CommandButton1_Click()
Sheets(“Sheet1″).Select
If Range(“A2″) = “” Then
linha = 2
Else
Range(“A2″).Select
Selection.End(xlDown).Select
linha = ActiveCell.Row + 1
End If
Cells(linha, 1) = TextBox1 & ” ” & TextBox2 & ” ” & ComboBox1
Cells(linha, 2) = Date
End Sub
4:Sub DeleteDups()
Dim x As Long
Dim LastRow As Long
LastRow = Range(“A65536″).End(xlUp).Row
For x = LastRow To 1 Step -1
If Application.WorksheetFunction.CountIf(Range(“A1:A” & x), Range(“A” & x).Text) > 1 Then
Range(“A” & x).EntireRow.Delete
End If
Next x
End Sub
Function ProdAbs(x As Range, y As Range) As Long
lin = 1
For Each xn In x.Cells
ProdAbs = ProdAbs + Abs(x(lin) * y(lin))
lin = lin + 1
Next
End Function