SOLVED

Centrar imagen en celda EXCEL

Copper Contributor

Buenos días a tod@s,

Necesito que unas imágenes que he colocado en una tabla EXCEL se centren con su celda correspondiente tanto en horizontal como verticalmente.

¿Puede alguien ayudarme?

Muchas gracias.

5 Replies

@Marchal1979 

There is no such feature.;

The closest you can get to it is selecting "Snap to grid" option when clicking over the image:

Image Format > Arrange > Aling >Snap to  grid

 

You can also align using the image as references and try the different options (Left,Right, center, etc.) 

 

JulianoPetrukio_0-1637834849977.png

 

Muchas gracias @Juliano-Petrukio por tu tiempo y respuesta. Eso ya lo he probado y no me convence demasiado. He mirado por la web y se puede hacer a través de Macros en la VBA.

He probado algunos pero o dan error o no lo realizan correctamente en toda la tabla. Tienes conocimiento de algún macro que solvente esto?
best response confirmed by Marchal1979 (Copper Contributor)
Solution

@Marchal1979 

Sure it is possible using vba. But what is important to know is that the size of the picture or the size of the cell matters.

 

JulianoPetrukio_2-1637835706907.png

You can try the following code considering the range A1:A100

 

Sub ArrangeImages()
    Dim shp As Shape, rng As Range, shpRow As Long
    
    Set rng = Range("A1:A100")
    For Each shp In ActiveSheet.Shapes
        If Not Intersect(Range(shp.TopLeftCell.Address), rng) Is Nothing Then
            shpRow = shp.TopLeftCell.Row
        
            With shp
                .Top = Range("A" & shpRow).Top + (Range("A" & shpRow).Height - .Height) / 2
                .Left = Range("A" & shpRow).Left + (Range("A" & shpRow).Width - .Width) / 2
            End With
        
        End If
    Next
End Sub

 

 

PERFECTO!!! Muchísimas gracias!!!
Any time my friend.
Once it solves your problem, dont forget to flag it as solved and hit the like button.
1 best response

Accepted Solutions
best response confirmed by Marchal1979 (Copper Contributor)
Solution

@Marchal1979 

Sure it is possible using vba. But what is important to know is that the size of the picture or the size of the cell matters.

 

JulianoPetrukio_2-1637835706907.png

You can try the following code considering the range A1:A100

 

Sub ArrangeImages()
    Dim shp As Shape, rng As Range, shpRow As Long
    
    Set rng = Range("A1:A100")
    For Each shp In ActiveSheet.Shapes
        If Not Intersect(Range(shp.TopLeftCell.Address), rng) Is Nothing Then
            shpRow = shp.TopLeftCell.Row
        
            With shp
                .Top = Range("A" & shpRow).Top + (Range("A" & shpRow).Height - .Height) / 2
                .Left = Range("A" & shpRow).Left + (Range("A" & shpRow).Width - .Width) / 2
            End With
        
        End If
    Next
End Sub

 

 

View solution in original post