Dynamic Image Spacing using VBA

Cat129

Board Regular
Joined
Oct 20, 2012
Messages
96
Hey All,

Need some help,

I am currently importing information from text files into excel with a loop. Each line in the text files relates to an image in a separate folder which it pulls in and then aligns it in the correct space. This works great when each text file is imported into its own sheet, as I can set the spacing exactly as it needs to be and the first image is always a certain space from the top. I am using the below

n is the folder where the images are stored

' For i = 0 To R - 1
' fstr = "file path" & n & "" & i & ".jpg"
' '''''''''''''ActiveSheet.Pictures.Insert(fstr).Select
' ActiveSheet.Shapes.AddPicture(fstr, False, True, 100, 100, -1, -1).Select
' Selection.ShapeRange.LockAspectRatio = msoTrue
' Selection.ShapeRange.Height = 50
' '''''''''''''''''Selection.ShapeRange.Width = 100
' Selection.ShapeRange.Rotation = 0#
' Selection.ShapeRange.Left = 5
' Selection.ShapeRange.Top = 24 + 60 * i
' Next


What I now need to do is have all the information import into one sheet. I have got all the text files to import below each other by using the below

Destination:=Range("B65536").End(xlUp).Offset(RowOffSet:=1))

How do I get the images that relate to the second, third etc text files to start importing 60 below the last one that was imported. All images can not be held in the same folder as these come from a different program and can not be moved or altered.

Hope someone out there can help me.

Thanks,
Cat
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,215,446
Messages
6,124,904
Members
449,194
Latest member
JayEggleton

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top