› Excel e gli applicativi Microsoft Office › codice da adattare
-
AutoreArticoli
-
Ciao a tutti,
in allegato file per conteggio ore. nel foglio dati, codice di scossa - neanche a dirlo - funzionante per i mesi 1-12.
ho bisogno della stessa cosa sul foglio planner. il giorno giovedì "gio" deve essere formattato in modo da ottenere "giov".
mi piacerebbe avere 2 codici distinti. ho fatto un copia/incolla del codice scossa e provato ad adattare per il foglio planner.
risultati catastrofici.
grazie.
Allegati:
You must be logged in to view attached files.Non so se ho capito bene quello che vuoi ottenere, ma qualcosa del genere può funzionare?
Il codice suggerito da scossa potresti modificarlo così:
Private Sub Worksheet_Change(ByVal Target As Range) Dim rCell As Range, ws As Worksheet Dim j As Integer, x As Integer If Target.Address = "$E$17" Then For j = 1 To 12 Set ws = ThisWorkbook.Worksheets(CStr(j)) For Each rCell In ws.Range("C11:C41") rCell.NumberFormat = "d ddd" If Right(rCell.Text, 3) = "gio" Then rCell.NumberFormat = "d dddv" Next rCell Next j Set ws = Worksheets("Planner") For x = 3 To 58 Step 5 For j = 3 To 33 ws.Cells(x, j).NumberFormat = "ddd" If ws.Cells(x, j).Text = "gio" Then ws.Cells(x, j).NumberFormat = "dddv" Next j Next x End If Set ws = Nothing Set rCell = Nothing End SubSe invece vuoi una procedura a parte, potresti utilizzare l'evento Activate del Foglio "Planner". Quindi a quel punto, il codice di scossa lo lasci così com'era, mentre nell'editor del Foglio "Planner" ci metti questo:
Option Explicit Private Sub Worksheet_Activate() Dim x As Integer, y As Integer Application.ScreenUpdating = False For x = 3 To 58 Step 5 For y = 3 To 33 Cells(x, y).NumberFormat = "ddd" If Cells(x, y).Text = "gio" Then Cells(x, y).NumberFormat = "dddv" Next y Next x Application.ScreenUpdating = True End SubPerò così diventa macchinoso. Ogni volta che Attivi il foglio parte la procedura...non so...vedi tu se conviene. A meno ché non vorresti una macro che attivi con un pulsante. Che poi non è altro che questa ma trasformata un una Sub.
-
AutoreArticoli
