Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

287
Views
Filtre la fila según el valor y copie todo lo que está debajo de ese valor en otra hoja

Actualmente tengo dos hojas: Sheet1 y Sheet2.

La Hoja 1 consta de información del sistema para elementos (Origen) y la Hoja 2 es la Hoja de destino (Objetivo).

Necesito poder filtrar la Columna A (Fuente) por el valor que se escribe en la Celda A3 en la Hoja de destino y luego pegar los datos en la primera fila disponible en la hoja de Destino. Parece estar fallando en la última línea de código, no estoy muy seguro de por qué. Agradezco cualquier ayuda.

El error que recibo es: Error en tiempo de ejecución '1004': Error en el método 'Rango' del objeto'_Hoja de trabajo'

 Sub CopyRowAndBelowToTarget() Dim wb As Workbook Dim src As Worksheet Dim tgt As Worksheet Dim match As Range Set wb = ThisWorkbook Set src = wb.Sheets("Sheet1") Set tgt = wb.Sheets("Sheet2") Dim lastCopyRow As Long Dim lastPasteRow As Long Dim lastCol As Long Dim matchRow As Long Dim findMe As String Sheets("sheet2").Activate ' specify what we're searching for findMe = Range("B1").Value 'Filter column for value src.Range("A1").AutoFilter Field:=1, Criteria1:=findMe ' find our search string in column A (1) Set match = src.Columns(1).Find(What:=findMe, After:=src.Cells(1, 1), _ LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _ SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False) ' figure out what row our search string is on matchRow = match.Row ' get the last row and column with data so we know how much to copy lastCopyRow = src.Range("A" & src.Rows.Count).End(xlUp).Row lastCol = src.Cells(1, src.Columns.Count).End(xlToLeft).Column ' find out where on our target sheet we should paste the results lastPasteRow = tgt.Range("A" & src.Rows.Count).End(xlUp).Row ' use copy/paste syntax that doesn't use the clipboard ' and doesn't select or activate src.Range(Cells(matchRow, 1), src.Cells(lastCopyRow, lastCol)).Copy _ tgt.Range("A" & lastPasteRow)
about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!