Consulta sobre ejecutar macro n veces en un rango de celdas
-
Posts
-
Esto: If Dir(ActiveWorkbook.Path & "\tb_Cobros.txt") <> "" Then existe = True Sustituye a esto: ruta = ActiveWorkbook.Path archivo = Dir(ruta & "\*.*") Do Until archivo = "" coleccion_archivos.Add archivo archivo = Dir() Loop For i = coleccion_archivos.Count To 1 Step -1 If coleccion_archivos(i) = "tb_Cobros.txt" Then existe = True End If Next i
-
By Gerson Pineda · Posted
Hola Seguro lo tuyo es un filtro avanzado... busca por aquí en el foro, sobre ese tema, hay variedad de soluciones que hemos aportado con el tiempo Saludos -
By Gerson Pineda · Posted
Hola Si bien es cierto que esto se puede hacer con Vba, lo que intentas hacer es improductivo, desde el punto de vista sobre el uso adecuado de Excel Te dejo una alternativa para que puedas filtrar a gusto, sin necesidad de ir buscando dentro de la misma base de datos esos criterios de filtro Saludos Libro3.xlsx -
By Víctor Pérez · Posted
Buenas, Estoy intentando realizar un macros que me lea los registros que cumplan una condición y me los pegue en otra hoja en la celda que le marco. He probado con esta macro, pero no me lo hace correcto me da error Sub Copiar_datos() -
By Benito Bartolomé · Posted
Buenas tardes; -He conseguido algo con este código, imagino que se podrá mejorar . -Si a alguno se le ocurre algo mejor que me lo diga. Saludos. Private Sub btn_Txt_Click(): On Error Resume Next Dim ruta As String, i As Integer, existe As Boolean, coleccion_archivos As New Collection, archivo As String Dim Sep As String, x As Integer, z As Integer, Cuenta As Integer ruta = ActiveWorkbook.path archivo = Dir(ruta & "\*.*") Do Until archivo = "" coleccion_archivos.Add archivo archivo = Dir() Loop For i = coleccion_archivos.Count To 1 Step -1 If coleccion_archivos(i) = "tb_Cobros.txt" Then existe = True End If Next i If existe = True Then z = MsgBox("Ya existe el archivo de texto.¿Deseas eliminardo?", vbYesNo) If z = vbYes Then Kill ActiveWorkbook.path & "\tb_Cobros.txt" existe = False Else Open ActiveWorkbook.path & "\tb_Cobros.txt" For Append As #1 End If End If If existe = False Then Open ActiveWorkbook.path & "\tb_Cobros.txt" For Output As #1 MsgBox "El archivo txt fue creado" End If Cuenta = frm_Cobros.ListBox1.ListCount Sep = ";" Print #1, "Fecha: " & Date For x = 0 To Cuenta - 1 If Me.ListBox1.Selected(x) = True Then MsgBox Me.ListBox1.List(x), vbInformation, "Registro" TextBox0 = ListBox1.List(x, 0) TextBox50 = ListBox1.List(x, 1) TextBox51 = ListBox1.List(x, 2) TextBox4 = Format(ListBox1.List(x, 3), "dd/mm/yyyy") TextBox5 = ListBox1.List(x, 4) TextBox10 = ListBox1.List(x, 5) TextBox6 = ListBox1.List(x, 6) TextBox11 = ListBox1.List(x, 7) TextBox7 = ListBox1.List(x, 8) TextBox8 = ListBox1.List(x, 9) TextBox12 = ListBox1.List(x, 10) Print #1, TextBox0 & Sep & TextBox50 & Sep & TextBox51 & Sep & TextBox4 & Sep & TextBox5 & Sep & TextBox10 & Sep & TextBox6 & Sep & TextBox11 & Sep & TextBox7 & Sep & TextBox8 & Sep & TextBox12 End If Next x Print #1, "-" Close #1 End Sub
-
-
Recently Browsing
No registered users viewing this page.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now