Condividi:        

allineare pulsanti in una cella

Vuoi potenziare i tuoi documenti Word? Non sai come si fa una macro in Excel? Devi creare una presentazione in PowerPoint?
Oppure sei passato a OpenOffice e non sei sicuro di come lavorare al meglio?

Moderatori: Anthony47, Flash30005

allineare pulsanti in una cella

Postdi raimea » 24/07/23 07:29

ciao

sempre in merito alla gestione di > oggetti in una cella
dopo aver scopeto che possono essere cancellati con vba
mi vien da chiedere:

e' possibile allineare l'oggetto al centro della cella con vba ?

in fgl generale
col C da C8:C
ci sono dei quadratini ai quali associo un colleg. ipertest.
vorrei riuscire , se possibile, a metterli al centro della relativa cella.

vi allego il file

https://www.dropbox.com/scl/fi/if5o7nloys1qq67rwkp0x/allinea-pulsanti.xlsm?rlkey=b9t7j4i0x5jue0aobz7jtynn9&dl=0


ciao
S.O. win10, Excell 2019
Avatar utente
raimea
Utente Senior
 
Post: 1414
Iscritto il: 11/02/10 07:33
Località: lago

Sponsor
 

Re: allineare pulsanti in una cella

Postdi Anthony47 » 24/07/23 11:47

Derivato dal codice dell’attuale Sub RemPulsanti:
Codice: Seleziona tutto
Sub CentraPulsanti()
Dim Shp As Shape
'
For Each Shp In ActiveSheet.Shapes
'    Debug.Print Shp.Type, Shp.Name, Shp.TopLeftCell.Address(0, 0)
    If Shp.Type = msoPicture Then
        If Shp.TopLeftCell.Column = 3 And Shp.TopLeftCell.Row > 8 Then                         'vedi nota**
            Shp.Top = Shp.TopLeftCell.Top + (Shp.TopLeftCell.Height - Shp.Height) / 2
            Shp.Left = Shp.TopLeftCell.Left + (Shp.TopLeftCell.Width - Shp.Width) / 2
        End If
    End If
Next Shp
End Sub


** forse deve essere If Shp.TopLeftCell.Column = 3 And Shp.TopLeftCell.Row >= 8?
Avatar utente
Anthony47
Moderatore
 
Post: 19229
Iscritto il: 21/03/06 16:03
Località: Ivrea

Re: allineare pulsanti in una cella

Postdi raimea » 24/07/23 17:37

ciao
e' tutto ok :o

grazie mille

ciao
S.O. win10, Excell 2019
Avatar utente
raimea
Utente Senior
 
Post: 1414
Iscritto il: 11/02/10 07:33
Località: lago

Re: allineare pulsanti in una cella

Postdi raimea » 17/02/24 20:53

ciao
sempre in merito agli oggetti, nelle celle di fgl generale

ora posso: cancellarli e allinearli.

chiedo

sarebbe possibile copiare il 1mo oggetto in cella C8
e incollarlo nelle successive 100 celle da C9 ?

allego il file

https://www.dropbox.com/scl/fi/ydbvf062ffkk03aooew2t/incolla-oggetti.xlsm?rlkey=dy8qlp8kgv3q4gjkfhkaxepb6&dl=0

ciao
S.O. win10, Excell 2019
Avatar utente
raimea
Utente Senior
 
Post: 1414
Iscritto il: 11/02/10 07:33
Località: lago

Re: allineare pulsanti in una cella

Postdi Anthony47 » 19/02/24 00:45

Modifica la tua Sub CentraPulsant come segue:
Codice: Seleziona tutto
Sub DuplicaEtCentraPulsanti()
Dim Shp As Shape
'----------------
' luglio 23 da pc-facile Anthony
' serve a duplicare e allineare i pulsantini in col C al centro delle celle
' http://www.pc-facile.com/forum/viewtopic.php?f=26&t=113041&p=664639&sid=511c36e58a902e069f48ca91d1fbed38#p664639
'-----------------------
Dim RemArea As String, taShp As Shape, myC As Range
RemArea = "C9:C100"
'
'Rimuovi Shapes dalle celle di destinazione:
For Each Shp In ActiveSheet.Shapes
    If Shp.Type = msoPicture Then
        If Not Application.Intersect(Range(RemArea), Shp.TopLeftCell) Is Nothing Then
            Shp.Delete
        Else
            If Shp.TopLeftCell.Address = "$C$8" Then
                Set taShp = Shp
            End If
        End If
    End If
Next Shp
'Copia e aggiungi:
taShp.Copy
DoEvents
For Each myC In Range(RemArea)
    DoEvents
    myC.PasteSpecial xlPasteAll
Next myC
'Centra nella cella
For Each Shp In ActiveSheet.Shapes
'    Debug.Print Shp.Type, Shp.Name, Shp.TopLeftCell.Address(0, 0)
    If Shp.Type = msoPicture Then
        If Shp.TopLeftCell.Column = 3 And Shp.TopLeftCell.Row >= 8 Then    ' 3=col C                      'vedi nota**
            Shp.Top = Shp.TopLeftCell.Top + (Shp.TopLeftCell.Height - Shp.Height) / 2
            Shp.Left = Shp.TopLeftCell.Left + (Shp.TopLeftCell.Width - Shp.Width) / 2
        End If
    End If
Next Shp
Range("C8").Select
End Sub

Noterai le modifiche per eliminare eventuali forme dalle celle destinatarie, copiarvi la cella campione, e infine allinearle col codice preesistente
Avatar utente
Anthony47
Moderatore
 
Post: 19229
Iscritto il: 21/03/06 16:03
Località: Ivrea

Re: allineare pulsanti in una cella

Postdi raimea » 19/02/24 16:51

ciao
tutto ok :eeh:
grazie
S.O. win10, Excell 2019
Avatar utente
raimea
Utente Senior
 
Post: 1414
Iscritto il: 11/02/10 07:33
Località: lago


Torna a Applicazioni Office Windows


Topic correlati a "allineare pulsanti in una cella":


Chi c’è in linea

Visitano il forum: Nessuno e 10 ospiti

cron