Send cell values to 2 other sheets according to condition

leobrice

New Member
Joined
Jun 14, 2024
Messages
37
Office Version
  1. 2013
Platform
  1. Windows
Greetings friends of MREXCEL, good evening.

The file is used to calculate costs of products and services, and the macros automate the process of calculations and procedures, however, has a detail and I have not been able to solve it, I explain the operation:

SHEET COSTOS PRODUCTOS IMPORTADOS:
In it the information of international products and services is registered, in it is placed:
A= Product or Service Name
B= IMPORTADO
C= Unit of Measurement
D= Country of Origin
E= Currency
F= Product Quantity
G= Cost per Unit
H= Exchange Rate
I= Formula
J= Expenses
K= Expense
L= Expense
M= Expense
N= Expense
O= Expense
P= Expense
R= Expense
S= Expense
T= Expense
U= Formula
V= SI/NO (HERE MACRO IS ACTIVATED WHEN SI IS ENTERED)
W= Formula
X= Formula

The following information is required to be sent to 2 sheets:

1)
COSTOS PRODUCTOS IMPORTADOS (A) to sheet PRECIOS PRODUCTOS Y SERVICIOS (A)
COSTOS PRODUCTOS IMPORTADOS (B) to sheet PRECIOS PRODUCTOS Y SERVICIOS (B)
COSTOS PRODUCTOS IMPORTADOS (C) to sheet PRECIOS PRODUCTOS Y SERVICIOS (C)
COSTOS PRODUCTOS IMPORTADOS (W) to sheet PRECIOS PRODUCTOS Y SERVICIOS (D)

2)
COSTOS PRODUCTOS IMPORTADOS (A) to sheet PUNTO DE EQUILIBRIO (A)

Notes:
- The macro is activated by placing SI in column V of COSTOS PRODUCTOS IMPORTADOS.
- After running the macro, the active sheet should be PRECIOS PRODUCTOS Y SERVICIOS.
- The cursor of COSTOS PRODUCTOS IMPORTADOS should be in column A, below the last product registered.
- The cursor of PRECIOS PRODUCTOS Y SERVICIOS should be in column E of the product that is sent with the macro.
- The cursor for PUNTO DE EQUILIBRIO should be in column B of the product that is sent with the macro.
The macro must allow to modify amounts of a product registered in COSTOS PRODUCTOS IMPORTADOS without running the macro again, since it exists and has been previously sent to the 2 sheets mentioned above and the new amount of column W must update the amount of column D of PRECIOS PRODUCTOS Y SERVICIOS.

Thank you in advance for your help

Translated with DeepL.com (free version)

CALCULADORA DE PRECIOS Y COSTOS DATCHEL PLUS1.xlsm
ACDEFGHIJKLMNOPQRSTUVWX
1Piscinas Aqualux S.A. DEFINITIVA
2COSTOS DE PRODUCTOS Y SERVICIOS IMPORTADOS
3PRODUCTOUNIDAD DE MEDIDA (seleccionar)PAÍS DE ORIGENMONEDACANTIDAD DE PRODUCTOCOSTO POR UNIDADTIPO DE CAMBIOTOTAL COSTO PRODUCTOARANCELESIMPUESTOSSEGUROSGASTOS DE NACIONALIZACIONTRANSPORTE NACIONALFLETESALMACENAJE O DEPÓSITOOTROS CONCEPTOS 1OTROS CONCEPTOS 2OTROS CONCEPTOS 3OTROS CONCEPTOS 4TOTAL COSTO PRODUCTO NACIONALIZADOCONFIRMAR INFORMACIONCOSTO PRODUCTO UNITARIO
4IMPORTADO(SI / NO)
5IMPORTADO AKiloESTADOS UNIDOSU$125,005,15540,00347.625,0010,0010,0010,0010,0010,0010,0010,0010,0010,0010,0010,00347.735,00SI2.781,88por Kilo
6IMP AKiloESTADOS UNIDOSU$100,003,15540,00170.100,0010,0010,0010,0010,0010,0010,0010,0010,0010,0020,0010,00170.220,00SI1.702,20por Kilo
7U$0,000,00NO0,000
8U$0,000,00NO0,000
9U$0,000,00NO0,000
COSTOS PRODUCTOS IMPORTADOS
Cell Formulas
RangeFormula
A1A1='INFORMACION GENERAL'!D5
J4J4=MONEDAS!C2
K4K4=MONEDAS!C2
L4L4=MONEDAS!C2
M4M4=MONEDAS!C2
N4N4=MONEDAS!C2
O4O4=MONEDAS!C2
P4P4=MONEDAS!C2
Q4Q4=MONEDAS!C2
R4R4=MONEDAS!C2
S4S4=MONEDAS!C2
T4T4=MONEDAS!C2
W4W4=MONEDAS!C2
W5:W9W5=IF(V5="SI",IFERROR(U5/F5,0),0)
X5:X9X5=C5
I4I4=MONEDAS!C2
I5:I9I5=F5*G5*H5
U4U4=MONEDAS!C2
U5:U9U5=SUM(I5:T5)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
X5:X10000Cell Value=0textNO
Cells with Data Validation
CellAllowCriteria
U5:V9Any value
A5:B10000Custom=CONTAR.SI($A$5:$A$10000;A5)<=1
C5:C10000List=UNIDADES
D5:D10000List=PAISES
E5:E10000List=MONEDAS


CALCULADORA DE PRECIOS Y COSTOS DATCHEL PLUS1.xlsm
ABCDE
1Piscinas Aqualux S.A. DEFINITIVA
2PRECIO DE VENTA DE PRODUCTOS Y SERVICIOS
3PRODUCTO / SERVICIOPRODUCTO NACIONALUNIDAD DE MEDIDACOSTO UNITARIO PRODUCTOVENTAS ESTIMADAS MENSUALES UNIDADES
4O
5IMPORTADO10.020
6IMPORTADOIMPORTADOKilo1.000,0010.000,00
7S1NACIONALunidad 10.000.000,0020,00
8dsdfsdNACIONAL52.000,00
9ANACIONALLitro1.875,00
10BNACIONALKilo11.555,56
PRECIOS PRODUCTOS Y SERVICIOS
Cell Formulas
RangeFormula
A1A1='INFORMACION GENERAL'!D5
D5D5=MONEDAS!C2
E5E5=SUM(E6:E9998)
Cells with Data Validation
CellAllowCriteria
A6:A10Custom=CONTAR.SI($A$5:$A$9998;A6)<=1


CALCULADORA DE PRECIOS Y COSTOS DATCHEL PLUS1.xlsm
ABC
1Piscinas Aqualux S.A. DEFINITIVA
2PUNTO DE EQUILIBRIO GLOBAL MENSUAL
3INFORME MENSUALVENTAS MENSUALES ESTIMADAS Y/O REALESVENTA PROYECTADA MENSUAL
4MES / AÑO: 09/21UNIDADES UNIDADES
5PRODUCTOS Y SERVICIOS TOTALES →275275
6S17575
7S28080
8IMPORTADO120120
PUNTO DE EQUILIBRIO
Cell Formulas
RangeFormula
A1A1='INFORMACION GENERAL'!D5
A2A2=IF('COSTOS FIJOS'!A5="MENSUAL","PUNTO DE EQUILIBRIO GLOBAL MENSUAL","PUNTO DE EQUILIBRIO GLOBAL ANUAL")
A3A3=IF('COSTOS FIJOS'!A5="MENSUAL","INFORME MENSUAL","INFORME ANUAL")
C3C3=IF('COSTOS FIJOS'!A5="MENSUAL","VENTA PROYECTADA MENSUAL","VENTA PROYECTADA ANUAL")
B5:C5B5=SUM(B6:B10000)
C6:C8C6=IF('COSTOS FIJOS'!$A$5="MENSUAL",B6,B6*12)
Cells with Data Validation
CellAllowCriteria
A6:A8Custom=CONTAR.SI($A$5:$A$10000;A6)<=1
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi @mumps how are you?

This is the other case I had told you about and I had told you it was very similar to the case you helped me solve. In fact, I used the final macro you made and made some changes to adapt it to this case.
I think it works fine, it sends the data from COSTS IMPORTED PRODUCTS to PRICES PRODUCTS AND SERVICES and to BALANCE POINT, but if you could check it please you handle very well the VBA topic.

The only thing I did not manage to do is to update the column D of PRICES PRODUCTS AND SERVICES, when the cost of the existing product varies in the sheet COSTS IMPORTED PRODUCTS.
Can you please help me. Thanks in advance

This is the macro with the adjustments I made:
Private Sub Worksheet_Activate()
Cells(Rows.Count, "A").End(xlUp).Offset(1).Select
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Intersect(Target, Range("V:V")) Is Nothing Or Target.Row < 5 Then Exit Sub
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim prod As Range, desWS1 As Worksheet, desWS2 As Worksheet
Set desWS1 = Sheets("PRECIOS PRODUCTOS Y SERVICIOS")
Set desWS2 = Sheets("PUNTO DE EQUILIBRIO")
With desWS2
.Activate
.Cells(.Rows.Count, "A").End(xlUp).Offset(1) = Target.Offset(, -21)
.Cells(.Rows.Count, "A").End(xlUp).Offset(, 1).Select
End With
Set prod = desWS1.Range("A:A").Find(Target.Offset(, -21), LookIn:=xlValues, lookat:=xlWhole)
If Not prod Is Nothing Then
With desWS1
.Activate
.Range("D" & prod.Row) = Target.Offset(, 1)
.Range("E" & prod.Row).Select
End With
Else
With desWS1
.Activate
.Cells(.Rows.Count, "A").End(xlUp).Offset(1).Resize(, 4).Value = Array(Target.Offset(, -21), Target.Offset(, -20), Target.Offset(, -19), Target.Offset(, 1))
.Cells(.Rows.Count, "C").End(xlUp).Offset(, 2).Select
End With
End If
MsgBox ("SE HA ENVIADO AL MODULO PRECIOS PRODUCTOS Y SERVICIOS, LA INFORMACIÓN DE ESTE PRODUCTO O SERVICIO." & vbCr & Chr(13) & _
"POR FAVOR COMPLETE LA INFORMACIÓN SOLICITADA" & Chr(13) & _
"!OPERACIÓN REALIZADA SATISFACTORIAMENTE¡"), vbInformation, "CALCULADORA DE PRECIOS Y COSTOS DATCHEL PLU"
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

Translated with DeepL.com (free version)
 
Upvote 0
Hi @mumps how are you.
Mumps can you help me with this case. It's very similar to the one that you resolved.
Thanks
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,111
Members
453,021
Latest member
Justyna P

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