Soporte con macro que se ajuste al texto y ponga bordes variables.
Su soporte con una macro que me aporto Dante, espero también pueda leer esta pregunta.
- Aparte que me guarde libros con el nombre del cliente sean también con fecha y hora (Con la función ahora) Ejemplo: SAGA FALABELLA, DEBERIA GUARDAR LOS LIBROS SAGA FALABELLA - 25.09.2017 1406
- Que se guarden y genere bordes dinámicos de acuerdo al tamaño del archivo. Asimismo, las columnas se auto ajusten a los datos. Les paso la programación y si me pueden aportar que código se adicionaría.
Adjunto fotos caso 1 y 2 y la programación.
Foto como guarda sin formato

Foto como debe guardarlo, bordes de acuerdo al texto y negrita la columna entrega y tiendas ( con código macro)

adjunto el código
Sub Por_OD()
'Aporte Ronald C.
'Como el usuario dinamico este codigo ayuda a capturar al cualquiera que se loggea
Dim struser As String
struser = CreateObject("WScript.Network").UserName
'Por.Dante Amor
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set l1 = ThisWorkbook
Set h1 = l1.ActiveSheet
Set h2 = l1.Sheets("Por OD")
'
If h1.FilterMode Then h1.ShowAllData
u = h1.Range("A" & Rows.Count).End(xlUp).Row
h1.Range("H:H").Copy h1.Range("AF1")
h1.[h1].Copy h1.[AG1]
h1.Range("AF1:AF" & u).RemoveDuplicates Columns:=1, Header:=xlYes
'
For i = 2 To h1.Range("AF" & Rows.Count).End(xlUp).Row
h1.[AG2] = h1.Cells(i, "AF")
h1.Range("D1:H" & u).AdvancedFilter Action:=xlFilterInPlace, _
CriteriaRange:=h1.Range("AG1:AG2"), Unique:=False
u2 = h1.Range("A" & Rows.Count).End(xlUp).Row
h2.Copy
Set l2 = ActiveWorkbook
Set h3 = l2.ActiveSheet
H1.Range("C2:F" & u2). Copy h3. Range("A9")
H1.Range("N2:N" & u2). Copy h3. Range("E9")
H1.Range("M2:M" & u2). Copy h3. Range("F9")
'
'Combinar
'Act. Por. Dante Amor
For j = 9 To h3.Range("A" & Rows.Count).End(xlUp).Row
contarsi = Application.WorksheetFunction.CountIf(h3.Columns(1), h3.Cells(j, "A"))
If contarsi > 1 Then
With h3.Range(h3.Cells(j, "A"), h3.Cells(j + contarsi - 1, "A"))
.Merge
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
End With
With h3.Range(h3.Cells(j, "F"), h3.Cells(j + contarsi - 1, "F"))
.Merge
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
End With
End If
Next
'l2.SaveAs Filename:="C:\Users\" & struser & "\Desktop\POR OD\" & h1.Cells(i, "AF") & ".xls", _
FileFormat:=xlExcel8, _
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
l2.Close
Next
If h1.FilterMode Then h1.ShowAllData
h1.Range("AF:AG").ClearContents
Application.ScreenUpdating = True
Range("A11:K10000").EntireColumn.AutoFit
Range("A11:K10000").EntireRow.AutoFit
MsgBox "Terminado"
End Sub
3 respuestas
Respuesta de Jaime Segura
2
Respuesta de Dante Amor
2
Respuesta de Programar Excel
1

