Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Picutres in Excel Cell
I've been trying to insert a picture into a cell and can only insert it into
the sheet. I've seen on this board that a cell can only contain text or a formula. Is there any way to get a picture to be associated with the cell such that if the rows are sorted the pictures sort with them? I can do this in Word tables, but Excel offers some features I want to utilize. Kind Regard |
#2
|
|||
|
|||
Hi
You can insert a picture in a cell.This will insert a picture into a single cell or a merged cell. Just change the range address and picture path/name to suit. Dim Rng As Range With Worksheets("Sheet1") Set Rng = .Range("B9").MergeArea .Shapes.AddPicture "C:\pictures\Sample.jpg", _ msoFalse, msoTrue, Rng.Left, Rng.Top, Rng.Width, Rng.Height End With I haven't tried sorting, but don't see why it should not sort with the cells. You can experiment with it and see. If you would like to see a workbook with 4 different ways of inserting pictures into cells, email me and I will send it to you. HTH Ken |
#3
|
|||
|
|||
No, you really *can't* insert a picture IN a cell. The picture exists in
the drawing layer above the cell. Whether it stays on top of the cell depends on the picture's properties. Your macro inserts a picture into the *worksheet* (hence your "Worksheets("Sheet1").Shapes.Add..."). But the cell is unchanged - its value and all other properties are the same as they were - it can only contain a constant or formula. Likewise, selecting the picture doesn't select the cell. In fact, you can't select the cell with the mouse if the picture covers it (you can, though, using arrow, tab or enter keys). OTOH, your guess is right that, if you select the column with the pictures, the pictures will sort, but *only* if the picture's .Placement property is set to either Move and size with cells, or Move but don't size with cells. Since you're assuming that the picture should fill the cell, you'd probably do better to set the picture to move and size with the cell, rather than the default move but don't size: With Worksheets("Sheet1").Range("B9").MergeArea .Parent.Shapes.AddPicture("C:\pictures\Sample.jpg" , _ False, True, .Left, .Top, .Width, .Height).Placement = _ xlMoveAndSize End With In article , "Ken Macksey" wrote: Hi You can insert a picture in a cell.This will insert a picture into a single cell or a merged cell. Just change the range address and picture path/name to suit. Dim Rng As Range With Worksheets("Sheet1") Set Rng = .Range("B9").MergeArea .Shapes.AddPicture "C:\pictures\Sample.jpg", _ msoFalse, msoTrue, Rng.Left, Rng.Top, Rng.Width, Rng.Height End With I haven't tried sorting, but don't see why it should not sort with the cells. You can experiment with it and see. If you would like to see a workbook with 4 different ways of inserting pictures into cells, email me and I will send it to you. HTH Ken |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Possible Lookup Table | Excel Worksheet Functions | |||
Copy cell format to cell on another worksht and update automatical | Excel Worksheet Functions | |||
How Can I make a cell flash in Excel | Excel Discussion (Misc queries) | |||
Excel: how to formulate conditional cell references | Excel Worksheet Functions | |||
Paste rows of numbers from Word into single Excel cell | Excel Discussion (Misc queries) |