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.

Problema al convertir cantidad con este símbolo delante: '

publicado

Hola,

Me han pasado un fichero, donde las cantidades vienen con ' delante, sería así:

'0,234

'123456,03

He utilizado este código para quitarle el símbolo porque necesito sumarlo, pero en algunos casos se queda así 0.234 y no me deja reemplazar el punto por la coma, solo quitárselo y quedarme con 0234 Os paso un fichero de ejemplo, por si se os ocurre otro modo de cambiar el formato. 

Muchas gracias!

 

With Worksheets("Hoja1")

    For i = 2 To .UsedRange.Rows(.UsedRange.Rows.Count).Row

        If Cells(i, "A").Value Like "'*" Then
		   Cells(i, "A").Value = Right(Cells(i, "A").Value, Len(Cells(i, "A").Value) - 1)
		End If
    Next

End With

 

ejemplo_texto.xlsm

Featured Replies

publicado
    With ActiveSheet.UsedRange
      .Replace "'", ""
      .Value = .Value
    End With

 

Editado el por Antoni

publicado
  • Autor
hace 1 hora, Antoni dijo:
    With ActiveSheet.UsedRange
      .Replace "'", ""
      .Value = .Value
    End With

 

Buenas, Antoni...

Es que me pasa lo mismo, después de pasar el código a esto:

 
'-288170,45

'-1,086

Se convierte en esto: 

-288170,45
-1.086

Se sustituye la coma por el punto... y te lo convierte a  - 1086 pero no -1,086

Lo conseguí con fórmula de excel (sin macro) así: =DERECHA(A1, LARGO(A1) - 1) 

Pero no consigo replicar esto mismo con VBA sin que pase lo mismo.

Gracias. 

 

publicado
  • Autor
hace 16 minutos , Gsus dijo:

Buenas, Antoni...

Es que me pasa lo mismo, después de pasar el código a esto:

 
'-288170,45

'-1,086

Se convierte en esto: 

-288170,45
-1.086

Se sustituye la coma por el punto... y te lo convierte a  - 1086 pero no -1,086

Lo conseguí con fórmula de excel (sin macro) así: =DERECHA(A1, LARGO(A1) - 1) 

Pero no consigo replicar esto mismo con VBA sin que pase lo mismo.

Gracias. 

 

Buenas, Antoni... lo conseguí así:

Sub quitarsimbolo()

With Worksheets("Hoja1")

 

    For i = 2 To .UsedRange.Rows(.UsedRange.Rows.Count).Row

        If Cells(i, "A").Value Like "'*" Then

        Cells(i, "A").NumberFormat = "@"
        Cells(i, "A").Value = Right(Cells(i, "A").Value, Len(Cells(i, "A").Value) - 1)
        
        Cells(i, "A").Value = CDbl(Cells(i, "A").Value)


        End If


    Next

End With

End Sub
 

Quizás es un poco cutrecillo :)

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.