Phil Smith
Active Member
- Joined
- Aug 13, 2004
- Messages
- 285
- Office Version
- 365
- Platform
- Mobile
Hi everyone.
Rather than insert images manually into 116 different cells, I would like to, if possible, have it done by VBA.
I used the macro recorder to see if it was possible and came up with the following:
I know certain parts of this will have to be changed for it to run automatically within my existing code.
For example:
will have to become
where diagramrow increases each time the loop runs.
To get the filename for the picture to be chosen
will have to become
where arrayrow increases each time the loop runs.
However, the code that has
at the start of it, I am not sure how this needs to be changed.
Any help greatly appreciated.
Thanks.
Phil
Rather than insert images manually into 116 different cells, I would like to, if possible, have it done by VBA.
I used the macro recorder to see if it was possible and came up with the following:
Code:
Range("B10").AddComment
Range("B10").Comment.Visible = False
Range("B10").Comment.Text Text:="Owner:" & Chr(10) & ""
Selection.ShapeRange.ScaleWidth 13.9, msoFalse,msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 28.2, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0.75
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 255, 255)
Selection.ShapeRange.Fill.BackColor.RGB = RGB(255, 255, 225)
Selection.ShapeRange.Fill.UserPicture "C:\Users\Owner\Pictures\IRUS Diagrams\401.jpg"
I know certain parts of this will have to be changed for it to run automatically within my existing code.
For example:
Code:
Range("B10").
will have to become
Code:
Sheets("Data").Cells(diagramrow,2).
where diagramrow increases each time the loop runs.
To get the filename for the picture to be chosen
Code:
"C:\Users\Owner\Pictures\IRUS Diagrams\401.jpg"
will have to become
Code:
"C:\Users\Owner\Pictures\IRUS Diagrams\" & Range("SundayDiagrams")(arrayrow, 1).Value & ".jpg"
where arrayrow increases each time the loop runs.
However, the code that has
Code:
Selection.
at the start of it, I am not sure how this needs to be changed.
Any help greatly appreciated.
Thanks.
Phil