Copiar valor no la formula

Buenas: Para Dam

Disculpa pero encontré un detalle que no me había dado cuentas antes...

La macro copia las formulas y no los valores este es el código..

Sub busqueda()
Application.ScreenUpdating = False
 Dim fec1 As Date Dim fec2 As Date 'Set h1 = Hoja2 Set h2 = Hoja11
 fec1 = UserForm1.ComboBox1 fec2 = UserForm1.ComboBox2 h = UserForm1.ComboBox3.List(UserForm1.ComboBox3.ListIndex, 1) c = UserForm1.ComboBox3.List(UserForm1.ComboBox3.ListIndex, 2) f = UserForm1.ComboBox3.List(UserForm1.ComboBox3.ListIndex, 3)
 Set h1 = Sheets(h) u2 = h2.Range("A" & Rows.Count).End(xlUp).Row h2.Range("A4:D" & u2).ClearContents h1.AutoFilterMode = False u = h1.Range("B" & Rows.Count).End(xlUp).Row h1.Range("B8:AZ" & u).AutoFilter Field:=1, _ Criteria1:=">=" & Format(fec1, "mm/dd/yyyy"), Operator:=xlAnd, Criteria2:="<=" & Format(fec2, "mm/dd/yyyy") h1.Range("B9:AZ" & u).AutoFilter Field:=5, _ Criteria1:=UserForm1.ComboBox4 On Error Resume Next h1.Range("B9:B" & u).SpecialCells(xlCellTypeVisible).Copy h2.Range("A4") h1.Range("D9:D" & u).SpecialCells(xlCellTypeVisible).Copy h2.Range("B4") h1.Range("F9:F" & u).SpecialCells(xlCellTypeVisible).Copy h2.Range("C4") h1.Range(c & f & ":" & c & u).SpecialCells(xlCellTypeVisible).Copy h2.Range("D4") h1.AutoFilterMode = False Hoja2.Select Application.ScreenUpdating = True End Sub

yo creo que aquí debe estar el problema

.SpecialCells(xlCellTypeVisible).Copy en como los copia!!!

Por favor gracias de antemano

1 respuesta

Respuesta
1

Prueba con este copiado

Sub busqueda()
Application.ScreenUpdating = False
 Dim fec1 As Date
 Dim fec2 As Date
 'Set h1 = Hoja2 Set h2 = Hoja11
 fec1 = UserForm1.ComboBox1
 fec2 = UserForm1.ComboBox2
 h = UserForm1.ComboBox3.List(UserForm1.ComboBox3.ListIndex, 1)
 c = UserForm1.ComboBox3.List(UserForm1.ComboBox3.ListIndex, 2)
 f = UserForm1.ComboBox3.List(UserForm1.ComboBox3.ListIndex, 3)
 Set h1 = Sheets(h)
 u2 = h2.Range("A" & Rows.Count).End(xlUp).Row
 h2.Range("A4:D" & u2).ClearContents
 h1.AutoFilterMode = False
 u = h1.Range("B" & Rows.Count).End(xlUp).Row
 h1.Range("B8:AZ" & u).AutoFilter Field:=1, _
 Criteria1:=">=" & Format(fec1, "mm/dd/yyyy"), Operator:=xlAnd, _
 Criteria2:="<=" & Format(fec2, "mm/dd/yyyy")
 h1.Range("B9:AZ" & u).AutoFilter Field:=5, _
 Criteria1:=UserForm1.ComboBox4
 On Error Resume Next
 h1.Range("B9:B" & u).SpecialCells(xlCellTypeVisible).Copy
 h2.Range("A4").PasteSpecial Paste:=xlPasteValues
 h1.Range("D9:D" & u).SpecialCells(xlCellTypeVisible).Copy
 h2.Range("B4").PasteSpecial Paste:=xlPasteValues
 h1.Range("F9:F" & u).SpecialCells(xlCellTypeVisible).Copy
 h2.Range("C4").PasteSpecial Paste:=xlPasteValues
 h1.Range(c & f & ":" & c & u).SpecialCells(xlCellTypeVisible).Copy
 h2.Range("D4").PasteSpecial Paste:=xlPasteValues
 h1.AutoFilterMode = False
 Hoja2.Select
 Application.ScreenUpdating = True
 End Sub

Gracias Dam ahora resulta!!

Pero sabes que el ultimo rango que copia que este caso seria

h1.Range(c & f & ":" & c & u).SpecialCells(xlCellTypeVisible).Copy h2.Range("D4").PasteSpecial Paste:=xlPasteValues

el rango queda marcado "seleccionado lo mismo cuando uno marca un rango y luego presiona control + c asi se queda ....

Como se puede dejar que al terminar la macro no marque nada??

Después de esta línea

Application.ScreenUpdating = True

Agrega esta

Application.CutCopyMode = False

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas