Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

macro con funcion select case que no funciona

publicado

Estimados

En esta ocasion necesito de vuestra ayuda, ya que  tengo una macro con la funcion select case para sumar, restar, multiplicar y dividir dos valores, pero no me funciona..Revise el codigo y no encuentro el error , ya que soy novato en esto de VB.

El ejercicio es el siguiente: En la celda A1 Y A2 estan los valores , en la celda B1 esta el signo de la operacion y el resultado debe ir en la celda A3, este es el codigo:

 

Public Sub ejemplo_select_case()

Dim Signo As String

Dim Valor1 As Integer, Valor2 As Integer, Total As Integer

      Valor1 = ActiveSheet.Range("A1").Value
      Valor2 = ActiveSheet.Range("A2").Value
      Signo = ActiveSheet.Range("B1").Value

Select Case Signo

       Case "+"
       
       Total = Valor1 + Valor2
       
       Case "-"
       
       Total = Valor1 - Valor2
       
       Case "x"
       
       Total = Valor1 * Valor2
       
       Case ":"
       
       Total = Valor1 / Valor2
       
       Case Else
       
       Total = 0
       
       End Select
       
       ActiveCell.Range("A3").Value = Total
       
       
End Sub

 

Espero me puedan ayudar

 

saludos 

meggido

 

Select Case.xlsm

Featured Replies

publicado

Hola

 

no tienes puesto +, sino espacio+, por eso no te funciona en tu ejemplo

A la sentencia  ActiveCell.Range("A3")..... del final donde pones el resultado le sobra el a¡ActiveCell

 

Me acabo de percatar que ya te ha contestado Mauricio

Un saludo desde Vitoria

 

 

 

publicado
  • Autor

Muchas gracias a todos  por vuestra ayuda

La macro me funciona al 100%

saludos

meggido

  • Silvia bloqueó este tema

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.