Macro copiar una tabla excel a word y que solo copie celdas con datos
El numero registros de la tabla excel varia practicamente todos los meses y lo que quiero es que solo se copien a word las celdas que contengan datos yo hice esta macro, pero como ven siempre selecciona un mismo rango.
Yo hice esta Macro pero como pueden ver siempre copia un mismo rango, con lo cual quedan bastantes hojas word sin registros.
ActiveWorkbook. Worksheets("LISTADO"). Sort. SortFields. Clear
ActiveWorkbook.Worksheets("LISTADO").Sort.SortFields.Add Key:=Range("B2:B530" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("LISTADO").Sort
.SetRange Range("A1:W530")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Sheets("LISTADO").Select
Rows("1:1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$W$523").AutoFilter Field:=2, Criteria1:="II GRUPO"
ActiveSheet.Range("$A$1:$W$523").AutoFilter Field:=8, Criteria1:="1"
Range("B1:G524").Select
Selection.Copy
Sheets().Select
Cells.Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Sheets("LISTADO").Select
Selection.Copy
Sheets().Select
ActiveSheet.Paste
Sheets("LISTADO").Select
Application.CutCopyMode = False
Range("U1:U524").Select
Selection.Copy
Sheets().Select
Range("G1").Select
ActiveSheet.Paste
Columns("A:A").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Columns("A:A").EntireColumn.AutoFit
Columns("B:B").ColumnWidth = 14.14
Columns("C:C").EntireColumn.AutoFit
Columns("D:D").EntireColumn.AutoFit
Columns("E:E").EntireColumn.AutoFit
Columns("F:F").ColumnWidth = 22.14
Rows("1:290").Select
Selection.RowHeight = 25
Range("A1:F290").Select
With Selection
.VerticalAlignment = xlCenter
.Orientation = 0
.AddIndent = True
.ReadingOrder = xlContext
.MergeCells = False
End With
patharch = ThisWorkbook.Path & "\listadocde.dotx"
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.documents.Add Template:=patharch, NewTemplate:=False, DocumentType:=0
Sheets().Select
Range("A1:F104").Select
Selection.Copy
objWord.Selection.PasteExcelTable False, True, False
Sheets("LISTADO").Select
ActiveSheet.Range("$A$1:$W$523").AutoFilter Field:=8
ActiveSheet.Range("$A$1:$W$523").AutoFilter Field:=2
Sheets().Visible = False
Sheets("LISTADO").Visible = False
Sheets("cp").Select