Advertisement
Guest User

Untitled

a guest
Jun 11th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. Private Sub CommandButton1_Click()
  3.  
  4. Dim iRow As Integer
  5. Dim myRange As Range
  6.  
  7. 'Make Sheet1 active
  8. Plan2.Activate
  9.  
  10. 'Conta quantas empresas tem (Quantas linhas tem)
  11. Set myRange = Range("A4", "A6000")
  12. lastRow = WorksheetFunction.CountA(myRange)
  13.  
  14.  
  15. Dim count As Integer
  16. count = 1
  17.  
  18. 'coluna que vai receber a soma
  19. Dim colunaSoma As Integer
  20. colunaSoma = 8
  21.  
  22. While count <= lastRow
  23.     'Soma todas as contas e coloca na Coluna = colunaSoma
  24.    Cells(count, colunaSoma).Value = Cells(count, 2).Value + Cells(count, 3).Value + Cells(count, 4).Value + Cells(count, 5).Value + Cells(count, 6).Value + Cells(count, 7).Value + Cells(count, 8).Value
  25.     count = count + 1
  26. Wend
  27.  
  28. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement