| | Post: 132 | Registrato il: 13/12/2015
| Città: MILANO | Età: 58 | Utente Junior | 2010 | | OFFLINE | |
|
31/03/2017 22:23 | |
Ciao a tutti,
Dopo aver eliminato le celle vuote e tolto gli spazi in eccesso:
Sub eliminarighe()
Dim ur As Integer
With Sheets("ore lavorate CC febbraio")
ur = .Cells(Rows.Count, 1).End(xlUp).Row
For n = ur To 2 Step -1
If .Cells(n, 1).Value = "" Then
.Cells(n, 1).EntireRow.Delete
End If
Next n
End With
End Sub
Sub anspazi()
riga = Cells(1, 1).End(xlDown).Row
For y = 1 To riga
Cells(y, 1) = Trim(Cells(y, 1))
Cells(y, 2) = Trim(Cells(y, 2))
Next y
End Sub
Vorrei sommare le ore dei dipendenti rispettando l'appartenenza al reparto indicata nel foglio Legenda.
Grazie per l'aiuto. [Modificato da BG66 31/03/2017 22:28] BG66
Excel 2010 |
|
| | Post: 234 | Registrato il: 31/01/2010
| Città: LIVORNO | Età: 61 | Utente Junior | 2016 | | OFFLINE | |
|
02/04/2017 07:31 | |
Ciao BG66 prova se ti può andare bene.....
Saluti
--------------
Marco
excel 2013 |
| | Post: 132 | Registrato il: 13/12/2015
| Città: MILANO | Età: 58 | Utente Junior | 2010 | | OFFLINE | |
|
02/04/2017 07:58 | |
Ciao Marco,
è un'approccio a cui non avevo pensato.
Grazie.
Aggiungo e condivido anche il contributo ricevuto dal grande Marius (Sorry ma nel copiarla l'identatura è saltata ??!??):
Sub Tot_Rep()
Dim sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet
Set sh1 = Sheets("ore lavorate CC febbraio")
Set sh2 = Sheets("Riesume")
Set sh3 = Sheets("Legenda")
ur1 = sh1.Cells(Rows.Count, 1).End(xlUp).Row
ur2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row
ur3 = sh3.Cells(Rows.Count, 1).End(xlUp).Row
'Dim tot(1 To ur2) As Double 'si tratta di ore
For i = 2 To ur2
rep = sh2.Cells(i, 1).Value
For j = 2 To ur1
cog = sh1.Cells(j, 1).Value
rp1 = Application.WorksheetFunction.VLookup(cog, sh3.Range("A2:B" & ur3), 2, 0)
If rp1 = rep Then tot = tot + sh1.Cells(j, 5).Value
Next j
sh2.Cells(i, 4) = tot: tot = 0
Next i
Set sh1 = Nothing
Set sh2 = Nothing
Set sh3 = Nothing
End Sub
Alla prossima. [Modificato da BG66 02/04/2017 14:14] BG66
Excel 2010 |
|
|