SOLVED

Centrar imagen en celda EXCEL

%3CLINGO-SUB%20id%3D%22lingo-sub-3004753%22%20slang%3D%22es-ES%22%3ECenter%20image%20in%20EXCEL%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3004753%22%20slang%3D%22es-ES%22%3E%3CP%3EGood%20morning%20to%20%3CA%20href%3D%22mailto%3Atod%40s%2C%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Etod%40s%2C%3C%2FA%3E%3C%2FP%3E%3CP%3EI%20need%20%3CEM%3Esome%20images%3C%2FEM%3E%20that%20I%20have%20placed%20in%20an%20EXCEL%20table%20to%20be%20%3CEM%3Ecentered%20with%20their%3C%2FEM%3E%20corresponding%20cell%20both%20horizontally%20and%20vertically.%3C%2FP%3E%3CP%3E%3CSTRONG%3ECan%20someone%20help%20me%3F%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EThanks%20a%20lot.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3004753%22%20slang%3D%22es-ES%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3004996%22%20slang%3D%22en-US%22%3ERe%3A%20Centrar%20imagen%20en%20celda%20EXCEL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3004996%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1229373%22%20target%3D%22_blank%22%3E%40Marchal1979%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20is%20no%20such%20feature.%3B%3C%2FP%3E%3CP%3EThe%20closest%20you%20can%20get%20to%20it%20is%20selecting%20%22Snap%20to%20grid%22%20option%20when%20clicking%20over%20the%20image%3A%3C%2FP%3E%3CP%3EImage%20Format%20%26gt%3B%20Arrange%20%26gt%3B%20Aling%20%26gt%3BSnap%20to%26nbsp%3B%20grid%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JulianoPetrukio_0-1637834849977.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F329394iE66BBA9E6DFBFA07%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22JulianoPetrukio_0-1637834849977.png%22%20alt%3D%22JulianoPetrukio_0-1637834849977.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3005013%22%20slang%3D%22es-ES%22%3ERe%3A%20Center%20image%20in%20EXCEL%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3005013%22%20slang%3D%22es-ES%22%3EThank%20you%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F767933%22%20target%3D%22_blank%22%3Every%20%40Juliano-Petrukio%3C%2FA%3E%20for%20your%20time%20and%20response.%20I've%20already%20tried%20that%20and%20it%20doesn't%20convince%20me%20too%20much.%20I've%20looked%20around%20the%20web%20and%20it%20can%20be%20done%20through%20Macros%20in%20the%20VBA.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%20I%20have%20tried%20some%20but%20they%20either%20give%20error%20or%20do%20not%20perform%20it%20correctly%20throughout%20the%20table.%20Are%20you%20aware%20of%20any%20macro%20that%20solves%20this%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3005117%22%20slang%3D%22en-US%22%3ERe%3A%20Centrar%20imagen%20en%20celda%20EXCEL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3005117%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1229373%22%20target%3D%22_blank%22%3E%40Marchal1979%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESure%20it%20is%20possible%20using%20vba.%20But%20what%20is%20important%20to%20know%20is%20that%20the%20size%20of%20the%20picture%20or%20the%20size%20of%20the%20cell%20matters.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JulianoPetrukio_2-1637835706907.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F329398i05C272377CBE2052%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22JulianoPetrukio_2-1637835706907.png%22%20alt%3D%22JulianoPetrukio_2-1637835706907.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EYou%20can%20try%20the%20following%20code%20considering%20the%20range%20A1%3AA100%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-visual-basic%22%3E%3CCODE%3ESub%20ArrangeImages()%0A%20%20%20%20Dim%20shp%20As%20Shape%2C%20rng%20As%20Range%2C%20shpRow%20As%20Long%0A%20%20%20%20%0A%20%20%20%20Set%20rng%20%3D%20Range(%22A1%3AA100%22)%0A%20%20%20%20For%20Each%20shp%20In%20ActiveSheet.Shapes%0A%20%20%20%20%20%20%20%20If%20Not%20Intersect(Range(shp.TopLeftCell.Address)%2C%20rng)%20Is%20Nothing%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20shpRow%20%3D%20shp.TopLeftCell.Row%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20With%20shp%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20.Top%20%3D%20Range(%22A%22%20%26amp%3B%20shpRow).Top%20%2B%20(Range(%22A%22%20%26amp%3B%20shpRow).Height%20-%20.Height)%20%2F%202%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20.Left%20%3D%20Range(%22A%22%20%26amp%3B%20shpRow).Left%20%2B%20(Range(%22A%22%20%26amp%3B%20shpRow).Width%20-%20.Width)%20%2F%202%0A%20%20%20%20%20%20%20%20%20%20%20%20End%20With%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20Next%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3005608%22%20slang%3D%22es-ES%22%3ERe%3A%20Center%20image%20in%20EXCEL%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3005608%22%20slang%3D%22es-ES%22%3EPERFECT!!!%20Thank%20you%20so%20much!!!%3C%2FLINGO-BODY%3E
Occasional 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 (Occasional 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.