Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

157
Vistas
Comparación de dos hojas en función de las condiciones

Hola, como dice el título, tengo que comparar dos hojas y obtener algunos detalles de los datos, consulte el código a continuación. La primera imagen es Sheet("scr"), la segunda Sheet("err_data"") la última es el resultado de que el código a continuación debe producir comentarios agregados al código.

Los productos deben coincidir, la fecha de publicación debe ser mayor o igual a la fecha de confirmación y el conteo mayor o igual al BUom de la cantidad disponible. Después de que esto sea cierto, debemos restar el BUom de la cantidad disponible del conteo y continuar con el siguiente producto.

 Sub Postings() '! Declare Variables Application.ScreenUpdating = False Dim Data, chk, i As Long Const REPORT = "Report" '! Store data of scr Table into Array Data = Sheets("scr").ListObjects(1).Range.Value '! Need to check how many of those went thru sheets("err_clean") With Sheets("err_clean").ListObjects(1) '! Loop data in Array NextIteration: For i = 2 To UBound(Data) '! Check for match Sheets("scr").Columns(1) with .ListColumns(1) chk = Application.Match(Data(i, 1), .ListColumns(1).Range, 0) If Not IsError(chk) Then 'If .DataBodyRange(chk - 1, 3).Value = 0 Then 'If condition is met need to Continue i = i + 1 and jump to Next iteration or Delete row but it get way to slow 'End If '! If match when condition met that's mean scr went thru err_clean If Data(i, 2) <= .DataBodyRange(chk - 1, 2).Value And .DataBodyRange(chk - 1, 3).Value - Data(i, 3) >= 0 Then 'And I have to decrease the quantity of .DataBodyRange(chk - 1, 3).Value .DataBodyRange(chk - 1, 3).Value = .DataBodyRange(chk - 1, 3).Value - Data(i, 3) '! Check if Sheet exists...If not create sheet If Evaluate("ISREF('" & REPORT & "'!A1)") = False Then Sheets.Add(, Sheets(Sheets.Count)).Name = REPORT '! Add header Range("A1").Resize(, 4).Value = .HeaderRowRange.Value End If '! Pass matched data to next available row but I NEED TO APPEND Data(i, 4) to columns number 5 no idea how Range("A" & Rows.Count).End(xlUp)(2).Resize(, 4).Value = .ListRows(chk - 1).Range.Value '& Data(i, 4) GoTo NextIteration ' Here when we have match and condition i am going to the next item this one went thru End If End If Next i End With Application.ScreenUpdating = True End Sub

Hoja("scr")

Hoja("err_clean")

ingrese la descripción de la imagen aquí

about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda