È soltanto un Pokémon con le armi o è un qualcosa di più? Vieni a parlarne su Award & Oscar!
 
Pagina precedente | 1 | Pagina successiva
Vota | Stampa | Notifica email    
Autore

stessa macro per 12 mesi

Ultimo Aggiornamento: 28/03/2016 19:44
Post: 31
Registrato il: 27/11/2007
Città: LOZIO
Età: 46
Utente Junior
offc 2010
OFFLINE
28/03/2016 09:23

ciao
in un file ho 12 fogli con i nomi dei mesi.
ho una macro che quando la avvio opera sul foglio attivo
-----
Sub coloro1()

If [b6] = "" Then
MsgBox "il mese e' vuoto...", vbCritical

'--------------------------
'RIATTIVO LE APPLICATION
With Application
.Calculation = xlCal
.EnableEvents = True
.ScreenUpdating = True
End With
'-----------------------------------
Exit Sub
End If


'---coloro 18,30----------------
RRs = 2
CCs = 24 ' colonna =X
NumS = Cells(RRs, CCs).Value
For RRT = 6 To 105
For cct = 8 To 38 ' 37=col Ay

If Cells(RRT, cct).Value = NumS Then
With Cells(RRT, cct)
.Interior.ColorIndex = 8 'colore cella
.Font.ColorIndex = 1 ' colore carattere
End With
End If
Next cct
Next RRT

'---coloro BASE----------------
RRs = 2
CCs = 23 ' colonna W
NumS = Cells(RRs, CCs).Value
For RRT = 6 To 105
For cct = 8 To 38

If Cells(RRT, cct).Value = NumS Then
With Cells(RRT, cct)
.Interior.ColorIndex = 36 'colore cella
.Font.ColorIndex = 1 ' colore carattere
End With
End If
Next cct
Next RRT
'---coloro 20----------------
RRs = 2
CCs = 25 ' colonna =Y
NumS = Cells(RRs, CCs).Value
For RRT = 6 To 105
For cct = 8 To 38

If Cells(RRT, cct).Value = NumS Then
With Cells(RRT, cct)
.Interior.ColorIndex = 1 'colore cella
.Font.ColorIndex = 19 ' colore carattere
End With
End If
Next cct
Next RRT

'---coloro r1 rep merc----------------
RRs = 2
CCs = 26 ' colonna =Z
NumS = Cells(RRs, CCs).Value
For RRT = 6 To 105
For cct = 8 To 38

If Cells(RRT, cct).Value = NumS Then
With Cells(RRT, cct)
.Interior.ColorIndex = 4 'colore cella
.Font.ColorIndex = 1 ' colore carattere
End With
End If
Next cct
Next RRT

'---coloro r2 rep domen----------------
RRs = 2
CCs = 27 ' colonna =AA
NumS = Cells(RRs, CCs).Value
For RRT = 6 To 105
For cct = 8 To 38

If Cells(RRT, cct).Value = NumS Then
With Cells(RRT, cct)
.Interior.ColorIndex = 7 'colore cella
.Font.ColorIndex = 1 ' colore carattere
End With
End If
Next cct
Next RRT
'----adatto largh col-----------------------
Columns("C:Al").ColumnWidth = 4
Columns("g").ColumnWidth = 1


Range("AK1").Select

'-------------
Call evidenziaB ' metto cornice b3-b2
Call EvidenziaLL ' evidenzio LL dal lun.ven
'-----------




Range("a2").Select

ActiveWindow.DisplayGridlines = False 'protegge il fgl

End Sub
----------------

vorrei poter aggiungere un ciclo , in modo che quando sono in un mese qualunque ed avvio tale macro
questa operi anche sugli altri 11 mesi.

via allego il file:
https://dl.dropboxusercontent.com/u/96374724/raggruppo%20turni.rar

https://dl.dropboxusercontent.com/u/96374724/raggruppo%20turni.rar

grazie - ciao
[Modificato da raimea 28/03/2016 10:08]
wind 10 & office 2010
Post: 3.058
Registrato il: 13/03/2012
Città: LIVORNO
Età: 78
Utente Master
2010
OFFLINE
28/03/2016 17:42

prova questa
Sub coloro1()
For Each sh In Worksheets
  With sh
    If sh.Name <> "generale" Then
    If .Range("b6") = "" Then
         MsgBox "il mese e' vuoto...", vbCritical
         
         With Application
            .Calculation = xlCal
            .EnableEvents = True
            .ScreenUpdating = True
         End With
    End If
    For CCS = 23 To 27
        RRs = 2
        NumS = .Cells(RRs, CCS).Value
        For RRT = 6 To 105
          For cct = 8 To 38  ' 37=col Ay
            If .Cells(RRT, cct).Value = NumS Then
               With .Cells(RRT, cct)
                   If CCS = 24 Then .Interior.ColorIndex = 8 '24colore cella
                   If CCS = 23 Then .Interior.ColorIndex = 36  '23colore cella
                   If CCS = 25 Then .Interior.ColorIndex = 19 ' 25colore carattere
                   If CCS = 27 Then .Interior.ColorIndex = 7  '27colore cella
                   
                   If CCS = 26 Then .Interior.ColorIndex = 4  '26colore cella
                   .Font.ColorIndex = 1 ' colore carattere
               End With
            End If
          Next cct
        Next RRT
   Next
 '----adatto largh col-----------------------
   Columns("C:Al").ColumnWidth = 4
   Range("AK1").Select
       
 '-------------
   Call evidenziaB  ' metto cornice b3-b2
   Call EvidenziaLL ' evidenzio LL dal lun.ven
 '-----------
   Range("a2").Select
   ActiveWindow.DisplayGridlines = False  'protegge il fgl
   End If
  End With
Next
End Sub

----------
Win 10 - Excel 2010
allega un file di esempio, guadagnerai tempo tu e lo farai risparmiare a chi ti aiuta
Post: 31
Registrato il: 27/11/2007
Città: LOZIO
Età: 46
Utente Junior
offc 2010
OFFLINE
28/03/2016 18:52

ciao
siamo vicini ma non del tutto
attalmente la macro NON colora:

le celle che contengono il numero 3 =( Y2), di nero carattere bianco

e non colora la lettera B =(U2), di verde caratt bianco , nella giornata di domenica
negli altri fogli ma lo colora sole nel foglio attivo

non colora B di sabato colore azzurro carattere bianco

ciao
wind 10 & office 2010
Post: 3.059
Registrato il: 13/03/2012
Città: LIVORNO
Età: 78
Utente Master
2010
OFFLINE
28/03/2016 19:06

io ti ho dato lo spunto, ora tocca a te il miglioramento, devi lavorare qui
               With .Cells(RRT, cct)
                   If CCS = 24 Then .Interior.ColorIndex = 8 '24colore cella
                   If CCS = 23 Then .Interior.ColorIndex = 36  '23colore cella
                   If CCS = 25 Then .Interior.ColorIndex = 19 ' 25colore carattere
                   If CCS = 27 Then .Interior.ColorIndex = 7  '27colore cella
                    
                   If CCS = 26 Then .Interior.ColorIndex = 4  '26colore cella
                   .Font.ColorIndex = 1 ' colore carattere
               End With

----------
Win 10 - Excel 2010
allega un file di esempio, guadagnerai tempo tu e lo farai risparmiare a chi ti aiuta
Post: 32
Registrato il: 27/11/2007
Città: LOZIO
Età: 46
Utente Junior
offc 2010
OFFLINE
28/03/2016 19:44

ma ! [SM=x423023]

se ci arrivavo non chiedevo

grazie comunque

ciao
[Modificato da raimea 28/03/2016 19:44]
wind 10 & office 2010
Vota:
Amministra Discussione: | Chiudi | Sposta | Cancella | Modifica | Notifica email Pagina precedente | 1 | Pagina successiva
Nuova Discussione
 | 
Rispondi
Feed | Forum | Bacheca | Album | Utenti | Cerca | Login | Registrati | Amministra
Tutti gli orari sono GMT+01:00. Adesso sono le 16:33. Versione: Stampabile | Mobile | Regolamento | Privacy
FreeForumZone [v.6.1] - Copyright © 2000-2024 FFZ srl - www.freeforumzone.com