If con or para varias condiciones

07/12/2004 - 04:55 por Compumakro | Informe spam
Amigos:
La siguiente fórmula porqué no me funciona ni en OffXP ni en Off97?

If Cells(3, 5) = 4 Or 6 Or 8 Or 10 then
Cells(3, 7) = 15000
End If
If Cells(3, 5) = 12 Or 14 Or 16 then
Cells(3, 7) = 18000
End If
If Cells(3, 5) = "S" Or "M" then
Cells(3, 7) = 20000
End If
If Cells(3, 5) = "L" Or "XL" then
Cells(3, 7) = 22000
End If

Gracias
Oscar

Preguntas similare

Leer las respuestas

#16 Compumakro
09/12/2004 - 03:48 | Informe spam
KL
Gracias, Parece que está funcionando ahora sí. Espero que al usarlo para la
carga completa funcione bien
Gracias

Oscar


"KL" <lapink2000(at)hotmail.com> escribió en el mensaje
news:
tienes q restablecer el valor de la variable Precio despues de cada
evaluacion para q no te lo asigne a otras celdas (abajo el codigo
corregido).

KL.

'--Inicio Codigo
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Precio As Variant
Dim Fila As Single

Fila = 3

Cells(Fila, 5) = UCase(Cells(Fila, 5))
Cells(Fila, 8) = UCase(Cells(Fila, 8))
Cells(Fila, 11) = UCase(Cells(Fila, 11))
Cells(Fila, 14) = UCase(Cells(Fila, 14))
Cells(Fila, 17) = UCase(Cells(Fila, 17))

If Not IsDate(Cells(Fila, 1)) Then Exit Sub

Select Case Year(Cells(Fila, 1))
Case 2004
Select Case Cells(Fila, 5)
Case 4, 6, 8, 10: Precio = 15000
Case 12, 14: Precio = 18000
Case "S", "M": Precio = 20000
Case "L", "XL": Precio = 22000
End Select
Cells(Fila, 7) = Precio
Precio = ""

Select Case Cells(Fila, 8)
Case 4, 6, 8, 10: Precio = 24000
Case 12, 14: Precio = 28000
Case "S", "M": Precio = 32000
Case "L", "XL": Precio = 34000
End Select
Cells(Fila, 10) = Precio
Precio = ""

Select Case Cells(Fila, 11)
Case 4, 6, 8, 10: Precio = 16500
Case 12, 14, 16: Precio = 18400
Case "S", "M": Precio = 19800
Case "L", "XL": Precio = 21500
End Select
Cells(Fila, 13) = Precio
Precio = ""

Select Case Cells(Fila, 14)
Case 4, 6, 8, 10: Precio = 13000
Case 12, 14: Precio = 15500
Case "S", "M": Precio = 16800
Case "L", "XL": Precio = 17900
End Select
Cells(Fila, 16) = Precio
Precio = ""

Select Case Cells(Fila, 17)
Case 10, 12: Precio = 22000
Case 14, 16: Precio = 15500
Case 28, 30, 32: Precio = 16800
Case 34, 36: Precio = 17900
End Select
Cells(Fila, 19) = Precio
Precio = ""

Case 2005
Select Case Cells(Fila, 5)
Case 4, 6, 8, 10: Precio = 16000
Case 12, 14: Precio = 19000
Case "S", "M": Precio = 21000
Case "L", "XL": Precio = 23000
End Select
Cells(Fila, 7) = Precio
Precio = ""

Select Case Cells(Fila, 8)
Case 4, 6, 8, 10: Precio = 28000
Case 12, 14: Precio = 32000
Case "S", "M": Precio = 35000
Case "L", "XL": Precio = 39000
End Select
Cells(Fila, 10) = Precio
Precio = ""

Select Case Cells(Fila, 11)
Case 4, 6, 8, 10: Precio = 18500
Case 12, 14, 16: Precio = 20400
Case "S", "M": Precio = 21800
Case "L", "XL": Precio = 23500
End Select
Cells(Fila, 13) = Precio
Precio = ""

Select Case Cells(Fila, 14)
Case 4, 6, 8, 10: Precio = 14500
Case 12, 14: Precio = 16800
Case "S", "M": Precio = 18100
Case "L", "XL": Precio = 19200
End Select
Cells(Fila, 16) = Precio
Precio = ""

Select Case Cells(Fila, 17)
Case 10, 12: Precio = 23000
Case 14, 16: Precio = 16500
Case 28, 30, 32: Precio = 18800
Case 34, 36: Precio = 19900
End Select
Cells(Fila, 16) = Precio
Precio = ""
End Select

Cells(Fila, 20) = Cells(Fila, 6) * Cells(Fila, 7) + _
Cells(Fila, 9) * Cells(Fila, 10) + _
Cells(Fila, 12) * Cells(Fila, 13) + _
Cells(Fila, 15) * Cells(Fila, 16) + _
Cells(Fila, 18) * Cells(Fila, 19)

Cells(Fila, 21) = Cells(Fila, 4) - Cells(Fila, 20)
End Sub
'--Fin Codigo

"KL" <lapink2000(at)hotmail.com> wrote in message
news:%
Compumakro,

Con el codigo q te puse en un posting mas abajo esto q dices no deberia
ocurrir.

KL

"Compumakro" wrote in message
news:
Fernando:
A qué se debe los Precios que se dan por "generación expontánea"?...
Pues sin datos en las celdas que lo generarían no deben aparecer. Esto
crea un problema, pues si por error se digita una cantidad la va a
multiplicar enseguida o por lo que sea... no debe estar ahí.

Gracias y Saludos

Oscar


"Fernando Arroyo" escribió en el mensaje
news:
Tienes que cambiar el tipo de la variable Precio. El problema que tienes
se debe a que está declarada como integer (entero), pero en varias
líneas del código se le intenta asignar un valor superior a 32767, que
es el máximo para este tipo de variables. Si en el código sustituyes
Integer por Long (si el precio no va a tener nunca decimales) o Double
(si pudiera tenerlos), tendrás resuelto el problema.
Un saludo.


Fernando Arroyo
MS MVP - Excel


"Compumakro" escribió en el mensaje
news:
KL:
No estoy fortalecido en VBA, por eso generalmente hago las preguntas a
medias, para forzar el cerebro a pensar y a razonar. Ya he avanzado
mucho en
esto, gracias a todo el grupo. Tengo que hacerle un reconocimiento a
Hector
Miguel y a Fernando Arroyo. (Hay 2 o 3 que se me escapan).
Antes de preguntar busco en los "Hilos" lo que necesito saber para no
sobrecargar a los maestros del Excel. Sin embargo, a veces termino
haciendo
lo que estoy evitando. Y ese es el caso de ahora:
Tengo Problemas con: "J3", "M3", "P3" y "S3" = Me marca un precio sin
razón
aparente $32.000.

Tengo un problema con Cells(3, 8) ,,,Cells(3, 10) = Precio: "Error de
Desbordamiento.".

Adjunto el Archivo con datos de prueba para su ensayo.

Muchas gracias

Oscar















email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una pregunta AnteriorRespuesta Tengo una respuesta
Search Busqueda sugerida