data in colonna



  • data in colonna
    di giupeppe (utente non iscritto) data: 14/02/2013 10:23:30

    salve a tutti
    ho un problema con una macro che trovate sotto
    il mio problema e che nei fogli che mi crea ho bisogno che nella colonna D
    ci sia il formato "m/d/yyyy"
    mi potete per favore aiutare?

    Grazie mille


     
    Sub CreaFogli2()
    
     
    
        Dim wb As Workbook
        Dim shA As Worksheet
        Dim shB As Worksheet
        Dim shC As Worksheet
        Dim rng As Range
        Dim oRange As Range
        Dim vCol As Variant
        Dim colAccount As Collection
        
        Dim lRiga As Long
        Dim lRigaF As Long
        
        If ThisWorkbook.path = vbNullString Then
            MsgBox "Devi prima salvare la cartella corrente"
            Exit Sub
        End If
        
        With Application
            .ScreenUpdating = False
            .DisplayAlerts = False
        End With
        
        With ThisWorkbook
            Set shA = .Worksheets("Sap")
            Set shB = .Worksheets("Template")
        End With
        
        Set wb = Application.Workbooks.Add
        
        Set colAccount = New Collection
        
        With shA
            lRiga = .Cells(.Rows.Count, 1).End(xlUp).Row
            .Range("A1:A" & lRiga).AdvancedFilter _
                Action:=xlFilterInPlace, Unique:=True
            Set rng = .Range("A2:A" & lRiga).SpecialCells(xlCellTypeVisible)
            On Error Resume Next
            For Each oRange In rng
                colAccount.Add Item:=oRange.Value, Key:=CStr(oRange.Value)
                DoEvents
            Next oRange
            On Error GoTo 0
            .ShowAllData
            For Each vCol In colAccount
                .Range("A1").AutoFilter Field:=1, Criteria1:=vCol
                lRigaF = .AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Count - 1
                shB.Copy Before:=wb.Worksheets("Sheet1")
                Set shC = wb.Worksheets("Template")
                With shC
                    .Name = vCol
                    .Range("C10").Value = vCol
                    .Range("C11").Formula = "=VLOOKUP(C10,'[Lean.xlsm]Trial Balance'!$A$1:$E$284,2,0)"
                    .Range("F15").Formula = "=VLOOKUP(C10,'[Lean.xlsm]Trial Balance'!$A$1:$E$284,3,0)"
                    .Range("G15").Formula = "=VLOOKUP(C10,'[Lean.xlsm]Trial Balance'!$A$1:$E$284,4,0)"
                    If lRigaF > 1 Then
                        .Range("B17:B" & (15 + lRigaF)).EntireRow.Insert
                    End If
                End With
                .Range("B2:H" & lRiga).SpecialCells(xlCellTypeVisible).Copy
                shC.Range("B17").PasteSpecial Paste:=xlPasteValues
            Next vCol
            With wb
                .Worksheets(Array("Sheet1", "Sheet2", "Sheet3")).Delete
                
            End With
            .AutoFilterMode = False
        End With
        
    
        With Application
            .CutCopyMode = False
            .ScreenUpdating = True
            .DisplayAlerts = True
        End With
    
     
    
        Set rng = Nothing
        Set shA = Nothing
        Set shB = Nothing
        Set shC = Nothing
        Set wb = Nothing
    
     
    
    End Sub



  • di Vecchio Frac data: 14/02/2013 12:06:38

    [D:D].NumberFormat = "m/d/yyyy"

    ?





  • di Riccardo (utente non iscritto) data: 14/02/2013 12:07:39

    Non è sufficiente aggiungere nel codice le seguenti istruzioni?


    Columns("D:D").Select
    Range("D7").Activate
    Selection.NumberFormat = "mm/dd/yyyy"




  • di giupeppe (utente non iscritto) data: 14/02/2013 12:16:56

    cosi mi da tutti i numeri in formato data non solo quelli nella colonna D :(



  • di giupeppe (utente non iscritto) data: 14/02/2013 12:25:12

    Grazie mille vecchio frac
    ogni tanto mi perdo

    volevo chiedervi visto che mi divide un elenco in tanti fogli

    se volessi dividere i fogli 1 e 2
    in file separati come posso fare?
    grazie mille



  • di Vecchio Frac data: 14/02/2013 20:25:37

    Il metodo più rapido è con un copia incolla in un nuovo workbook, e poi salvi.