Condividi tramite

Copia originale di celle

Anonimo
2014-11-12T12:07:03+00:00

Ciao a tutti

Attenzione domanda contorta

In una form, chiamamola Gigi, CommandButton1 esegue questo:

  1. restituisce al foglio attivo, range [C4:C21] e range [E4:E21]..........>  C___n° è fisso     /     E___è definito da utente

   che nel foglio creato definisce  questo

   ------------------------------------------------------------

      Private Sub CommandButton1_Click()

'********************************************************************

'*        INIZIO COPIA DATI IN FOGLIO                               *

'********************************************************************

Activesheet.Range("A4") = TextBox33.text

Activesheet.Range("C4") = TextBox1.text

Activesheet.Range("D4") = TextBox49.text

Activesheet.Range("E4") = TextBox17.text

Activesheet.Range("F4") = ComboBox1.text

Activesheet.Range("A5") = TextBox34.text

Activesheet.Range("C5") = TextBox2.text

Activesheet.Range("D5") = TextBox50.text

Activesheet.Range("E5") = TextBox18.text

Activesheet.Range("F5") = ComboBox2.text

Activesheet.Range("A6") = TextBox35.text

Activesheet.Range("C6") = TextBox3.text

Activesheet.Range("D6") = TextBox51.text

Activesheet.Range("E6") = TextBox19.text

Activesheet.Range("F6") = ComboBox3.text

Activesheet.Range("A7") = TextBox36.text

Activesheet.Range("C7") = TextBox4.text

Activesheet.Range("D7") = TextBox52.text

Activesheet.Range("E7") = TextBox20.text

Activesheet.Range("F7") = ComboBox4.text

Activesheet.Range("A8") = TextBox37.text

Activesheet.Range("C8") = TextBox5.text

Activesheet.Range("D8") = TextBox53.text

Activesheet.Range("E8") = TextBox21.text

Activesheet.Range("F8") = ComboBox5.text

Activesheet.Range("A9") = TextBox38.text

Activesheet.Range("C9") = TextBox6.text

Activesheet.Range("D9") = TextBox54.text

Activesheet.Range("E9") = TextBox22.text

Activesheet.Range("F9") = ComboBox6.text

Activesheet.Range("A10") = TextBox39.text

Activesheet.Range("C10") = TextBox7.text

Activesheet.Range("D10") = TextBox55.text

Activesheet.Range("E10") = TextBox23.text

Activesheet.Range("F10") = ComboBox7.text

Activesheet.Range("A11") = TextBox40.text

Activesheet.Range("C11") = TextBox8.text

Activesheet.Range("D11") = TextBox56.text

Activesheet.Range("E11") = TextBox24.text

Activesheet.Range("F11") = ComboBox8.text

Activesheet.Range("A14") = TextBox41.text

Activesheet.Range("C14") = TextBox9.text

Activesheet.Range("D14") = TextBox57.text

Activesheet.Range("E14") = TextBox25.text

Activesheet.Range("F14") = ComboBox9.text

Activesheet.Range("A15") = TextBox42.text

Activesheet.Range("C15") = TextBox10.text

Activesheet.Range("D15") = TextBox58.text

Activesheet.Range("E15") = TextBox26.text

Activesheet.Range("F15") = ComboBox10.text

Activesheet.Range("A16") = TextBox43.text

Activesheet.Range("C16") = TextBox11.text

Activesheet.Range("D16") = TextBox59.text

Activesheet.Range("E16") = TextBox27.text

Activesheet.Range("F16") = ComboBox11.text

Activesheet.Range("A17") = TextBox44.text

Activesheet.Range("C17") = TextBox12.text

Activesheet.Range("D17") = TextBox60.text

Activesheet.Range("E17") = TextBox28.text

Activesheet.Range("F17") = ComboBox12.text

Activesheet.Range("A18") = TextBox45.text

Activesheet.Range("C18") = TextBox13.text

Activesheet.Range("D18") = TextBox61.text

Activesheet.Range("E18") = TextBox29.text

Activesheet.Range("F18") = ComboBox13.text

Activesheet.Range("A19") = TextBox46.text

Activesheet.Range("C19") = TextBox14.text

Activesheet.Range("D19") = TextBox62.text

Activesheet.Range("E19") = TextBox30.text

Activesheet.Range("F19") = ComboBox14.text

Activesheet.Range("A20") = TextBox47.text

Activesheet.Range("C20") = TextBox15.text

Activesheet.Range("D20") = TextBox63.text

Activesheet.Range("E20") = TextBox31.text

Activesheet.Range("F20") = ComboBox15.text

Activesheet.Range("A21") = TextBox48.text

Activesheet.Range("C21") = TextBox16.text

Activesheet.Range("D21") = TextBox64.text

Activesheet.Range("E21") = TextBox32.text

Activesheet.Range("F21") = ComboBox16.text

'********************************************************************

'*        FINE COPIA DATI IN FOGLIO                                 *

'********************************************************************

2. restituisce al foglio attivo un range per copiare dati nel foglio desiderato gestito da una sub, input ha una sub output la sua............Esempio

'********************************************************************

'*        INIZIO COPIA DATI IN REPORT-IN                            *

'********************************************************************

Activesheet.Range("AC4") = TextBox70.Value

  Activesheet.Range("AE4") = TextBox33.text

  Activesheet.Range("AD4") = TextBox1.text

  Activesheet.Range("AF4") = TextBox17.text

Activesheet.Range("AC5") = TextBox70.text

  Activesheet.Range("AE5") = TextBox34.text

  Activesheet.Range("AD5") = TextBox2.text

  Activesheet.Range("AF5") = TextBox18.text

Activesheet.Range("AC6") = TextBox70.text

  Activesheet.Range("AE6") = TextBox35.text

  Activesheet.Range("AD6") = TextBox3.text

  Activesheet.Range("AF6") = TextBox19.text

Activesheet.Range("AC7") = TextBox70.text

  Activesheet.Range("AE7") = TextBox36.text

  Activesheet.Range("AD7") = TextBox4.text

  Activesheet.Range("AF7") = TextBox20.text

Activesheet.Range("AC8") = TextBox70.text

  Activesheet.Range("AE8") = TextBox37.text

  Activesheet.Range("AD8") = TextBox5.text

  Activesheet.Range("AF8") = TextBox21.text

Activesheet.Range("AC9") = TextBox70.text

  Activesheet.Range("AE9") = TextBox38.text

  Activesheet.Range("AD9") = TextBox6.text

  Activesheet.Range("AF9") = TextBox22.text

Activesheet.Range("AC10") = TextBox70.text

  Activesheet.Range("AE10") = TextBox39.text

  Activesheet.Range("AD10") = TextBox7.text

  Activesheet.Range("AF10") = TextBox23.text

Activesheet.Range("AC11") = TextBox70.text

  Activesheet.Range("AE11") = TextBox40.text

  Activesheet.Range("AD11") = TextBox8.text

  Activesheet.Range("AF11") = TextBox24.text

Activesheet.Range("AC12") = TextBox70.text

  Activesheet.Range("AE12") = TextBox41.text

  Activesheet.Range("AD12") = TextBox9.text

  Activesheet.Range("AF12") = TextBox25.text

Activesheet.Range("AC13") = TextBox70.text

  Activesheet.Range("AE13") = TextBox42.text

  Activesheet.Range("AD13") = TextBox10.text

  Activesheet.Range("AF13") = TextBox26.text

Activesheet.Range("AC14") = TextBox70.text

  Activesheet.Range("AE14") = TextBox43.text

  Activesheet.Range("AD14") = TextBox11.text

  Activesheet.Range("AF14") = TextBox27.text

Activesheet.Range("AC15") = TextBox70.text

  Activesheet.Range("AE15") = TextBox44.text

  Activesheet.Range("AD15") = TextBox12.text

  Activesheet.Range("AF15") = TextBox28.text

Activesheet.Range("AC16") = TextBox70.text

  Activesheet.Range("AE16") = TextBox45.text

  Activesheet.Range("AD16") = TextBox13.text

  Activesheet.Range("AF16") = TextBox29.text

Activesheet.Range("AC17") = TextBox70.text

  Activesheet.Range("AE17") = TextBox46.text

  Activesheet.Range("AD17") = TextBox14.text

  Activesheet.Range("AF17") = TextBox30.text

Activesheet.Range("AC18") = TextBox70.text

  Activesheet.Range("AE18") = TextBox47.text

  Activesheet.Range("AD18") = TextBox15.text

  Activesheet.Range("AF18") = TextBox31.text

Activesheet.Range("AC19") = TextBox70.text

  Activesheet.Range("AE19") = TextBox48.text

  Activesheet.Range("AD19") = TextBox16.text

  Activesheet.Range("AF19") = TextBox32.text

Call test1

'********************************************************************

'*        FINE COPIA DATI IN REPORT-IN                              *

'******************************************************************

Ora utilizzo questa sub per aggiornare i dati e gestire una combobox...... esempio

Sub test1()

 Activesheet.Range("AC4:AF19").Copy

 Worksheets("Report-In").Select

'ora con xlUp troviamo l'ultima cella occupata della colonna A; poichè abbiamo 'bisogno di incollare nella cella immediatamente sotto che è liberà, usiamo Offset 'per spostarci e selezionare detta cella libera, in unica istruzione:

 Range("A65536").End(xlUp).Offset(1, 0).Select

'e ora incollo i dati.

With ActiveCell

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _

:=False, Transpose:=False

End With

Activesheet.Select

    End Sub


Ho provato la formattazione condizionale...............ma con copia non va'

Per favore vorrei sapere e capire come gestire la copia delle celle 

grazie

ciao

Microsoft 365 e Office | Excel | Per la casa | Windows

Domanda bloccata. Questa domanda è stata eseguita dalla community del supporto tecnico Microsoft. È possibile votare se è utile, ma non è possibile aggiungere commenti o risposte o seguire la domanda.

0 commenti Nessun commento

5 risposte

Ordina per: Più utili
  1. Anonimo
    2014-11-15T21:35:18+00:00

    scusate il ritardo nel post

    ho fatto delle modifiche al codice della form "frmIn16"

    ho tolto il pezzo di codice finale che riportava al foglio23

    l'ho cambiato, non confondetevi ho volutamente messo un riferimento vecchio

    [Code]

    '********************************************************************

    '*        INIZIO COPIA DATI IN FOGLIO23                             *

    '********************************************************************

     Sheets("Foglio23").Range("AA2") = Activesheet.Range("Z1")

     Sheets("Foglio23").Range("AB2") = Activesheet.Range("Y1")

     Sheets("Foglio23").Range("AC1") = Activesheet.Range("E4")

     Sheets("Foglio23").Range("AC2") = Activesheet.Range("C4")

     Sheets("Foglio23").Range("AD1") = Activesheet.Range("E5")

     Sheets("Foglio23").Range("AD2") = Activesheet.Range("C5")

     Sheets("Foglio23").Range("AE1") = Activesheet.Range("E6")

     Sheets("Foglio23").Range("AE2") = Activesheet.Range("C6")

     Sheets("Foglio23").Range("AF1") = Activesheet.Range("E7")

     Sheets("Foglio23").Range("AF2") = Activesheet.Range("C7")

     Sheets("Foglio23").Range("AG1") = Activesheet.Range("E8")

     Sheets("Foglio23").Range("AG2") = Activesheet.Range("C8")

     Sheets("Foglio23").Range("AH1") = Activesheet.Range("E9")

     Sheets("Foglio23").Range("AH2") = Activesheet.Range("C9")

     Sheets("Foglio23").Range("AI1") = Activesheet.Range("E10")

     Sheets("Foglio23").Range("AI2") = Activesheet.Range("C10")

     Sheets("Foglio23").Range("AJ1") = Activesheet.Range("E11")

     Sheets("Foglio23").Range("AJ2") = Activesheet.Range("C11")

     Sheets("Foglio23").Range("AK1") = Activesheet.Range("E14")

     Sheets("Foglio23").Range("AK2") = Activesheet.Range("C14")

     Sheets("Foglio23").Range("AL1") = Activesheet.Range("E15")

     Sheets("Foglio23").Range("AL2") = Activesheet.Range("C15")

     Sheets("Foglio23").Range("AM1") = Activesheet.Range("E16")

     Sheets("Foglio23").Range("AM2") = Activesheet.Range("C16")

     Sheets("Foglio23").Range("AN1") = Activesheet.Range("E17")

     Sheets("Foglio23").Range("AN2") = Activesheet.Range("C17")

     Sheets("Foglio23").Range("AO1") = Activesheet.Range("E18")

     Sheets("Foglio23").Range("AO2") = Activesheet.Range("C18")

     Sheets("Foglio23").Range("AP1") = Activesheet.Range("E19")

     Sheets("Foglio23").Range("AP2") = Activesheet.Range("C19")

     Sheets("Foglio23").Range("AQ1") = Activesheet.Range("E20")

     Sheets("Foglio23").Range("AQ2") = Activesheet.Range("C20")

     Sheets("Foglio23").Range("AR1") = Activesheet.Range("E21")

     Sheets("Foglio23").Range("AR2") = Activesheet.Range("C21")

    Call test5a

    '********************************************************************

    '*        FINE COPIA DATI IN FOGLIO23                               *

    '********************************************************************

    [\code]

    Adesso praticamente copia direttamente i dati

    In Foglio23 ho fatto la "FormattazioneCondizionale" qui

    https://dl.dropboxusercontent.com/u/94475965/variazione_15_11_a.JPG

    per esempio se AC1, che corrisponde ad E4 del foglio creato, è vuoto......

       AC2, che corrisponde a C4 del foglio creato, ha il font di colore ROSSO

    TEST5a ha questo codice, ma notate le varie prove ['] inutili

    [Code]

    Sub test5a()

    Sheets("Foglio23").Select

        Range("AA2:AR2").Select

        Selection.Copy

        Range("A65536").End(xlUp).Offset(1, 0).Select

        'Selection.PasteSpecial Paste:=xlPasteValidation, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

        'Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

        'Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

        'Range("AA1:AR20").ClearFormats

       ' ActiveSelection.ClearFormat

    'Sheets("Foglio23").Select

        End Sub

    [\code]

    La guida riferisce

    http://msdn.microsoft.com/en-us/library/office/ff837425(v=office.15).aspx

    [quote]

    Nome Valore Descrizione
    xlPasteAll -4104 Tutto sarà incollato.
    xlPasteAllExceptBorders 7 Tutto tranne i confini verrà incollato.
    xlPasteAllMergingConditionalFormats 14 Tutto sarà incollato e formati condizionali saranno fusi.
    xlPasteAllUsingSourceTheme 13 Tutto sarà incollato utilizzando il tema di origine.
    xlPasteColumnWidths 8 Larghezza della colonna copiato viene incollato.
    xlPasteComments -4144 I commenti sono incollati.
    xlPasteFormats -4122 Formato sorgente copiato viene incollato.
    xlPasteFormulas -4123 Le formule vengono incollati.
    xlPasteFormulasAndNumberFormats 11 Formule e formati numerici vengono incollati.
    xlPasteValidation 6 Convalide vengono incollati.
    xlPasteValues -4163 I valori vengono incollati.
    xlPasteValuesAndNumberFormats 12 Valori e formati numerici vengono incollati.

    [\quote]

    In aggiunta a tutto vorrei aggiungere un immagine per specificare una cosa

    https://dl.dropboxusercontent.com/u/94475965/variazione_15_11_b.JPG

    Ho raggiunto il traguardo di avere sul foglio23 le celle con font evidenziato (rosso) SE le celle collegate sono vuote

    MA quello che non capisco è il fatto che se aggiungo una riga al Foglio23 - A9:R9 - le celle poi riprendono il valore della Formattazione Condizionale..............

      -  rosso  (Immagine, ("A9:R11")

      -  idem per nero (Immagine, ("A12:R13")

      - idem per rosso (Immagine, ("A4:R16")

    Ossia, se la Sub test5a dice di copiare e mettere nella prima riga sotto, perckè tu prendi i vecchi valori?

    Potete consigliarmi per favore

    ciao

    La risposta è stata utile?

    0 commenti Nessun commento
  2. Anonimo
    2014-11-13T16:53:51+00:00

    Mauro, le ho provate tutte

    ti posto le immagini dell'ultima 

    questo è l'inizio, come vedi, per ex. E100.00 e E100.01 sono occupati e sono neri(carattere)

    E100.02 è libero ed è rosso.............

    Poi mi sposto nel Foglio23 e vedo questo

    non combaciano

    la sub è questa

    nota che nel registratore di macro ho scelto la singola cella di, in questo caso, XA100   >  ("C5") che equivale a E100.01 e la stessa lo copiata con Incolla Speciale, Mantieni FOrmattazione Originale, e anche  con Formattazione Valori e Origine

    in definitiva in foglio23 non copia in maniera corretta i dati presenti nel foglio(X) creato dalla form ModIns

    e simultaneamente non li riporta nella combobox (cmbox3)

    La risposta è stata utile?

    0 commenti Nessun commento
  3. Anonimo
    2014-11-13T14:35:54+00:00

    <cut>

    spero in vs delucidazioni

    Registra una macro, copia un valore, incollalo selezionando in Incolla speciale quello di tuo interesse. Vedi poi il risultato.

    La risposta è stata utile?

    0 commenti Nessun commento
  4. Anonimo
    2014-11-13T12:58:23+00:00

    dopo tutto questo ho pensato...............

    ma non è che per caso è questo?

    """"

    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

    """

    e se lo cambio cosi'?

    """

    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormat, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

    """

    bene mi dice che non l'ho dichiarato nelle variabili.............scherzi?

    se Paste:=xlPasteValues va bene

    xkè Paste:=xlPasteValuesAndNumberFormat, no!

    è una prova ok, ma se questo comando copia Valori e FormatoNumeri......

    ciao

    spero in vs delucidazioni

    La risposta è stata utile?

    0 commenti Nessun commento
  5. Anonimo
    2014-11-12T12:28:51+00:00

    ops ho dimenticato la cosa piu' importante

    SE , nella form1, Txtbox17 è vuota txtbox4 ha il carattere di colore rosso, vedi sopra

    MA la stessa formattazione deve essere rispettata in tutti i passaggi, ossia

    1. Nuovofoglio ("A1") Pippo > Rosso
    2. foglio " InputBox " ("A1") Pippo > Rosso

       NB questi hanno una localizzazione in verticale

    1. foglio23, prende i valori in orizzontale per popolare combobox

        ma se un valore, inizialmente, era rosso deve essere rosso

    La risposta è stata utile?

    0 commenti Nessun commento