El relleno

ColdGeorge

Active Member
Joined
Aug 21, 2012
Messages
407
Office Version
  1. 2016
Platform
  1. Windows
Hola amigos

En una columna tengo una lista de nombres, en otra hoja en una misma columna hay varias celdas con la palabra conductor, deseo colocar en la siguiente celda a la derecha el primer nombre de la lista, hasta completar las celdas, ¿Cuál es la mejor forma de realizar esta tarea? gracias de antemano por su ayuda.

ColdGeorge
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hola amigos

Mi búsqueda continúa y esto es lo que he logrado, aún así, no funciona como deseo, ¿alguna sugerencia?


Code:
Dim c As Range
Dim cell As Range
 
For Each c In Worksheets("Sheet1").Range("A1:A12").Cells
If c.Value <> "" Then
c.Copy
                              Sheets("Sheet2").Select
 
For Each cell In Worksheets("Sheet2").Range("A1").End(xlDown).Cells
                              If cell.Value = "CONDUCTOR" Then
                                            lMaxRows = Cells(Rows.Count, "A").End(xlUp).Row
                                            Range("A" & lMaxRows + 1).Offset(0, 1).Select
                                            Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
                                            Application.CutCopyMode = False                           
                              End If
Next
End If
Next

ColdGeorge
 
Upvote 0
Hola amigos

Aún no tengo éxito completo, pero he avanzado, eso creo, este es el código hasta ahora,

Code:
Dim c As Range
Dim d As Range

For Each c In Sheets("Hoja1").Range("A2:A6")
    If c.Value <> "" Then
        c.Copy
        Sheets("Hoja2").Select
    End If
Next        
For Each d In Sheets("Hoja2").Range("A5:A13")
        If d.Value = "CONDUCTOR" Then
            d.Offset(0, 1).PasteSpecial xlPasteValues
        End If
Next    
Application.CutCopyMode = False

Por alguna razón que no puedo resolver, hasta ahora, únicamente copia -o se muestra- el último nombre de la lista, cuando debería copiar el primero, luego el segundo, etc, gracias por su ayuda, ColdGeorge
 
Upvote 0
Bueno,

El siguiente le brindará los resultados que usted proveyó aquí.

Code:
Sub foo()

    Dim rngData As Excel.Range, _
        i&
    
    With Worksheets(1)
        Set rngData = .Range("A" & .Rows.Count).End(xlUp)
        Set rngData = .Range("A1").Resize(rngData.Row)
    End With
        
    rngData.Copy Worksheets(2).Range("A1")
    
    Set rngData = Worksheets(2).Range("A1").CurrentRegion
    With rngData
        Set rngData = .Offset(1).Resize(.Rows.Count - 1)
    End With
    With rngData
        .Cells(.Rows.Count, 1).Cut Worksheets(2).Range("B1")
        .Resize(.Rows.Count - 1).Cut Worksheets(2).Range("B2")
    End With
    Set rngData = Worksheets(2).Range("A1").CurrentRegion.Resize(, 1)
    With rngData
        .Formula = .Cells(1, 1).Formula
    End With
    
    For i = rngData.Rows.Count To 2 Step -1
        Worksheets(2).Rows(i).EntireRow.Insert
    Next i


End Sub
 
Last edited:
Upvote 0
Estimado Greg

Aprecio tu ayuda, voy a realizar varios ejercicios con este código y lo mantendré al tanto de los resultados, saludos y gracias.

ColdGeorge
 
Upvote 0
Hola Greg

Estoy complacido con los resultados de tu código, gracias.

ColdGeorge
 
Upvote 0

Forum statistics

Threads
1,214,561
Messages
6,120,239
Members
448,951
Latest member
jennlynn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top