Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
In un Range ad esempio B3:E100 con celle contenenti tutto del testo, come faccio ad aggiungere x spazi ad ogni cella fino a raggiungere una lunghezza massima di tot (ad esempio 10).
Mi spiego meglio, ad esempio:
in B3 ho "Pippo"
in C3 ho "Ciao Pluto"
eccetera ...
in questo caso C3 è la lunghezza massima che ho nel range e che ottengo con formula matriciale:
=MAX(LUNGHEZZA(B3:E100))
ora devo fare in modo che tutte le celle del range abbiano una lunghezza massima di 10, quindi ad esempio in B3, dovrò aggiungere dopo "Pippo" 5 spazi (" ")
Qualche suggerimento? Grazie mille e buona serata.
Ciao
Antonio
Co una macro la cosa è semplice:
Public Sub m()
On Error GoTo RigaErrore
Dim sh As Worksheet
Dim rng As Range
Dim lCar As Long
Dim c As Range
Set sh = ThisWorkbook.Worksheets("Foglio1")
With sh
Set rng = .Range("A1:A10")
For Each c In rng
c.Value = Mid(c.Value, 1, 10)
lCar = Len(c.Value)
If lCar < 10 Then
c.Value = c.Value & String(10 - lCar, " ")
End If
Next
End With
RigaChiusura:
Set c = Nothing
Set rng = Nothing
Set sh = Nothing
Exit Sub
RigaErrore:
MsgBox Err.Number & vbNewLine & Err.Description
Resume RigaChiusura
End Sub
Modifica il Range con il tuo.