ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Inserting pictures then sorting (https://www.excelbanter.com/excel-discussion-misc-queries/53183-inserting-pictures-then-sorting.html)

Dav

Inserting pictures then sorting
 

I have a sheet containing data in the first few columns then a column
containing references to pictures. Can these pictures be imported into
the cell next to the reference eg data is in columns A & B a reference
to a picture in columnC. If the pictures refered to in column C can be
imported into column D.

I can then sort by the data in columns A & B and print out the pictures
I am interested in.

Obviously this is a simplified version of what I require as there are
hundreds of lines of data but hopefully you will get the picture. I
could use file insert picture, but this would be highly time consuming
and hopefully the task can be automated with a macro, but I am fairly
new to writing macros




If anyone could help that would be great

Thanks :)

Dav


+-------------------------------------------------------------------+
|Filename: Example.txt |
|Download: http://www.excelforum.com/attachment.php?postid=3982 |
+-------------------------------------------------------------------+

--
Dav
------------------------------------------------------------------------
Dav's Profile: http://www.excelforum.com/member.php...o&userid=27107
View this thread: http://www.excelforum.com/showthread...hreadid=480860


Dave Peterson

Inserting pictures then sorting
 
Something like this might work for you:

Option Explicit
Sub testme01()

Dim testStr As String
Dim myCell As Range
Dim myRng As Range
Dim wks As Worksheet
Dim myPict As Picture

Set wks = Worksheets("sheet1")

With wks
.Pictures.Delete 'nice for testing.
Set myRng = .Range("c2", .Cells(.Rows.Count, "C").End(xlUp))
End With

For Each myCell In myRng.Cells
testStr = ""
On Error Resume Next
testStr = Dir(myCell.Value)
On Error GoTo 0

If testStr = "" Then
myCell.Offset(0, 1).Value = "Picture not found"
Else
With myCell.Offset(0, 1)
.ClearContents
Set myPict = .Parent.Pictures.Insert(myCell.Value)
myPict.Top = .Top
myPict.Left = .Left
myPict.Width = .Width
myPict.Height = .Height
myPict.Placement = xlMoveAndSize
End With
End If
Next myCell
End Sub


Dav wrote:

I have a sheet containing data in the first few columns then a column
containing references to pictures. Can these pictures be imported into
the cell next to the reference eg data is in columns A & B a reference
to a picture in columnC. If the pictures refered to in column C can be
imported into column D.

I can then sort by the data in columns A & B and print out the pictures
I am interested in.

Obviously this is a simplified version of what I require as there are
hundreds of lines of data but hopefully you will get the picture. I
could use file insert picture, but this would be highly time consuming
and hopefully the task can be automated with a macro, but I am fairly
new to writing macros

If anyone could help that would be great

Thanks :)

Dav

+-------------------------------------------------------------------+
|Filename: Example.txt |
|Download: http://www.excelforum.com/attachment.php?postid=3982 |
+-------------------------------------------------------------------+

--
Dav
------------------------------------------------------------------------
Dav's Profile: http://www.excelforum.com/member.php...o&userid=27107
View this thread: http://www.excelforum.com/showthread...hreadid=480860


--

Dave Peterson

Dav

Inserting pictures then sorting
 

:) That has saved a colleague a huge amount of work and will greatly add
value to our survey process as pictures of handwritten text can be
included with parts of the survey. Its made my day!

Dav


--
Dav
------------------------------------------------------------------------
Dav's Profile: http://www.excelforum.com/member.php...o&userid=27107
View this thread: http://www.excelforum.com/showthread...hreadid=480860



All times are GMT +1. The time now is 12:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com