Loop stopping at row 10

Jasen79

New Member
Joined
Nov 25, 2020
Messages
47
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Below is a code I had a lot of help with from user such as yourself.
This code worked well but now is stopping a row 10 and I can't see why!
Could one of you please be so kind to point out why this is happening and how I might fix it?
What should be happen in short is and does up to row 10, is the code will like at a cell, see if there is a xxx.jpg name, if there is then it looks it up in a folder from on the PC, and insert the picture, then loops on to the next row and cell.
Thank you for your help and insight.

Code:
Sub Pic_insert()

    Dim last_row As Long
    Dim cell As Range
    Dim col_num As Long
    Dim j As Long, i As Long

    last_row = Sheets(1).Range("I654").End(xlUp).Row
    
        Do While Sheets(1).Cells(last_row, 9) = 0
        last_row = last_row - 1
    Loop
    
    For j = 2 To last_row Step 1
    For i = 9 To 11 Step 1
                        
            InsertirPictures Cells(j, i)

        Next i
    Next j

End Sub
Sub InsertirPictures(cel As Range)
    ' Help from YKY & RoryA
    ' Personal Note: Below file path needs to be changed to where the IR photos are located!!!
    '
    Const fPath = "C:\Users\576186\Pictures\"

    Dim picPath As String

    picPath = fPath & cel.Value
    If Not Dir(picPath, vbDirectory) = vbNullString Then
        cel.Worksheet.Shapes.AddPicture Filename:=picPath, LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, _
        Top:=cel.Offset(, 0).Top, Left:=cel.Offset(, 0).Left, Width:=125, Height:=125

    End If

End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
I think we would need to see what the data in column I on Sheet1 looks like to properly decipher what is going on.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
2301 APL MASTER Test sheet.xlsm
ABCDEFGHIJK
1ISSUE #FLOORROOMWALL / Floor / Ceiling / or GRID LINESOVERHEAD / OCCUPIED SPACE / UNDERFLOORDESCRIPTION /LOCATIONTYPE TAGISSUE #PHOTOPHOTO 2PHOTO 3
21Basement020-HallWEST WALLOCCUPIED SPACEremember to link some picsABANDONED Conductor1TK1.jpgTK2.jpgTK3.jpg
32Basement020-HallSOUTH WALLOCCUPIED SPACE0ABANDONED Conductor2TK4.jpgEUCOM.JPGPAE.JPG
43Basement19SOUTH WALLOCCUPIED SPACE0ABANDONED Conductor3TK2.jpgTK1.jpgTK1.jpg
54Basement19SOUTH WALLOCCUPIED SPACE0Building Material Left in Wall4TK3.jpgTK4.jpgTK4.jpg
65Basement19SOUTH WALLOCCUPIED SPACE0Building Material Left in Wall5000
76Basement19SOUTH WALLOCCUPIED SPACE0ABANDONED Conductor6000
87Basement19CellingOVERHEAD0ABANDONED Conductor7000
98Basement19North WallOCCUPIED SPACE0Abandon Penetration8000
109Basement19North WallOCCUPIED SPACE0Abandon Penetration9000
1110Basement19CellingOVERHEAD0Building Material Left in Wall10000
1211Basement190OCCUPIED SPACE0ABANDONED HOLE11000
1312Basement19North WallOVERHEAD0ABANDONED Conductor12000
1413Basement19North WallOCCUPIED SPACE0ABANDONED Conductor13000
1514Basement19North WallOCCUPIED SPACE0Abandon Penetration14000
1615Basement020-HallNorth WallOCCUPIED SPACE0Abandon Penetration15000
1716Basement020-HallSouth WallOCCUPIED SPACE0ABANDONED Conductor16000
1817Basement020-HallSouth WallOCCUPIED SPACE0Abandon Penetration17000
1918Basement020-HallWest WallOCCUPIED SPACE0ABANDONED HOLE18000
2019Basement020-HallSouth WallOCCUPIED SPACE0ABANDONED HOLE19000
2120Basement19East WallOVERHEAD0Abandon Penetration20000
2221Basement18South WallOCCUPIED SPACE0Abandon Penetration21000
2322Basement18South WallOCCUPIED SPACE0Abandon Penetration22000
2423Basement18South WallOCCUPIED SPACE0Abandon Penetration23000
2524Basement18South WallOCCUPIED SPACE0ABANDONED Conductor24000
2625Basement18South WallOCCUPIED SPACE0ABANDONED Conductor25000
2726Basement18South WallOCCUPIED SPACE0ABANDONED Conductor26000
2827Basement18South WallOCCUPIED SPACE0Abandon Penetration27000
2928Basement18East WallOCCUPIED SPACE0Abandon Conduct Conductor28000
3029Basement19North WallOCCUPIED SPACE0Abandon Penetration29000
3130Basement20North WallOCCUPIED SPACE0Abandon Penetration30000
3231Basement21North WallOCCUPIED SPACE0Abandon Penetration31000
3332Basement22North WallOCCUPIED SPACE0Abandon Penetration32000
3433Basement23North WallOCCUPIED SPACE0Abandon Penetration33000
3534Basement015-ATrue CeilingOVERHEAD0Abandon Conduct Conductor34000
3635Basement017A Shower F.South WallOCCUPIED SPACE0Building Material Left in Wall35000
3736Basement017C BreastfeedSouth WallOCCUPIED SPACE0Building Material Left in Wall36000
3837Basement017D VestibuleNorth WallOCCUPIED SPACE0Abandon Penetration37000
3938Basement12North WallOCCUPIED SPACE0Building Material Left In Wall38000
4039Basement12North WallOCCUPIED SPACE0Building Material Left In Wall39000
4140Basement14North WallOCCUPIED SPACE0Building Material Left In Wall40000
4241Basement14North WallOCCUPIED SPACE0Building Material Left In Wall41000
4342Basement14South WallOCCUPIED SPACE0Building Material Left In Wall42000
4443Basement14South WallOCCUPIED SPACE0Building Material Left In Wall43000
4544Basement14South WallOCCUPIED SPACE0Building Material Left In Wall44000
4645Basement14South WallOCCUPIED SPACE0Building Material Left In Wall45000
4746Basement14South WallOCCUPIED SPACE0Building Material Left In Wall46000
4847Basement14North WallOCCUPIED SPACE0Building Material Left In Wall47000
4948Basement14North WallOCCUPIED SPACE0Building Material Left In Wall48000
5049Basement14North WallOCCUPIED SPACE0Building Material Left In Wall49000
APL DISTRIBUTE
Cell Formulas
RangeFormula
A1:A50A1='APL MASTER'!A2
B1:G50B1='APL MASTER'!D2
H1:H50H1=A1
I1:K50I1='APL MASTER'!J2
Named Ranges
NameRefers ToCells
'APL DISTRIBUTE'!_FilterDatabase='APL DISTRIBUTE'!$A$1:$G$5H1
'APL MASTER'!_FilterDatabase='APL MASTER'!$A$2:$R$171A1
'APL DISTRIBUTE'!Print_Area='APL DISTRIBUTE'!$A:$KH1
I think we would need to see what the data in column I on Sheet1 looks like to properly decipher what is going on.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
When running on the data you provided, it seems to correctly make all the updates in the range I2:K5.

If it is not working for, enter these two formulas in any blank cells and tell me what they return:
=ISNUMBER(I6)
=LEN(I6)
 
Upvote 0
ok, So what I did wrong was this... I didn't send the right code. So sorry.
I took the original code and tried to use it in another excel sheet.

VBA Code:
Sub DD()

    Dim last_row As Long
    Dim cell As Range
    Dim col_num As Long
    Dim j As Long, i As Long

    last_row = Sheets(1).Range("I150").End(xlUp).Row
  
        Do While Sheets(1).Cells(last_row, 10) = 0
        last_row = last_row - 1
    Loop
  
    For j = 3 To last_row Step 1
    For i = 10 To 14 Step 1
                      
            InsertirPictures Cells(j, i)

        Next i
    Next j

End Sub
Sub InsertirPictures(cel As Range)
    ' Help from YKY & RoryA
    ' Personal Note: Below file path needs to be changed to where the IR phots are located!!!
    '
    Const fPath = "C:\Users\576186\Pictures\Small\"

    Dim picPath As String

    picPath = fPath & cel.Value
    If Not Dir(picPath, vbDirectory) = vbNullString Then
        cel.Worksheet.Shapes.AddPicture Filename:=picPath, LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, _
        Top:=cel.Offset(, 0).Top, Left:=cel.Offset(, 0).Left, Width:=125, Height:=125

    End If

End Sub

EUCOM REPORT 20210328.xlsm
JKLMN
3START PHOTOPROGRESS PHOTO 1PROGRESS PHOTO 2PROGRESS PHOTO 3PROGRESS PHOTO 4
4B7C07465-8E9C-4370-B251-3A810E3E4C55.JPG0D6A2C58-C6BB-44D2-B2EC-6DAC854C0C0E.JPG65489773-D813-41A7-BA35-756F5A6D8B36.JPGC9F041AF-0EBB-4F0E-A7D0-2B24E3B0A382.JPGx
5AF540F63-303D-42BD-ACFC-B23C694CA57B.JPG1A01CAD0-91B9-4198-B0F5-DACE33663BB6.JPGE59197D1-2B2E-422F-8418-A28B0FC472B4.JPGxx
69128C8D3-F70B-49B0-A68F-4C4AF59F7AD3.JPG6FE7B169-238F-4980-B087-2AD82402E2D5.JPGF051A79C-59DD-4919-A1B1-253BB08D1C20.JPGDE1BB8D6-16A1-4C97-8408-FFF8671DA07A.JPGB0E542D1-E81B-400C-8DF7-C8DEF413370F.JPG
7B7CAFBB3-F74A-49B3-B404-B29F72816F27.JPG3C6EF6EC-A6B4-4C67-A17B-C397CA067D7A.JPG204AC7F6-C4B3-41E7-A23D-7BD18781998D.JPGAF335062-4538-4259-B004-F483B73A8A34.JPGB2AD9D65-6B04-4B8B-82ED-5D0E7BA7BEA4.JPG
8EFE72E0D-8A33-4738-B6AF-37D345553BBB.JPGD8A9AB44-05A2-4BB6-83AD-052721ACCD27.JPGxxx
9E7054AA4-1BE1-4C6B-B936-B68A0D8F8B7A.JPGB70F2F56-CDF5-49DB-91C9-83D02BB6FA25.JPG82DDD60E-7CF5-41BF-BB30-904F6759ADF9.JPG075984AA-C916-4C65-9C25-A1F8E8FE65C6.JPGB1CABA9C-C71F-431B-B749-C5528D55F717.JPG
10E12FB184-D0F6-4551-BF52-EB854849D802.JPG2CDD9AA8-55EA-4B54-A65B-190B9068B1E1.JPGxxx
11538F65A7-CF96-46D6-95C2-A9ED76DB514C.JPGC837E179-BF29-45E0-AC95-F8374C3B77F3.JPGC2335F95-1683-4933-8C41-0DBBB6C8602B.JPG0B393D2C-6BA1-489F-ADF2-B69A1F67595F.JPG6252A560-A8A6-40E9-85E6-1F576343A1C5.JPG
12D25DC9A9-6F02-45CA-8A56-F8CFA903B645.JPG11B94480-0E61-4CC6-928E-7446EA16EAB1.JPGxxx
13EFD7E6FD-4666-42CD-84C7-B1F0E71C709C.JPG8346FEA1-5B87-404A-B592-77C4A7C856B4.JPG9E57F882-91BD-4C7F-AE54-EB2595C51824.JPG947F34A9-12AF-4ED9-983C-4D479677A8A4.JPG6C68970B-F04D-4558-BDB4-310A5A93E556.JPG
142EFF7E69-0F37-44EC-B3EC-190F5AF636CA.JPG36AD826F-9113-4C48-AC4A-6BF19162FF49.JPGD57B351C-CB08-4E17-B9DB-55986137B76B.JPG204E6CE2-8881-460F-ADF1-339F6474A0AE.JPGx
157FD78A74-D6A4-43E0-8262-057EAB5CB0A5.JPGAF69EA3F-6D8F-4423-9105-0D2D47C406D7.JPGxxx
160D496432-1F95-4A5C-9952-1D63BC974BDA.JPGF4A597CE-84F2-4463-9F51-798AB6B93FC9.JPG847E92B5-B236-4D29-A84C-985815861332.JPGF3D02600-F552-4ABE-A656-7A023A96F546.JPG60CAFC21-0146-40FE-8351-2E943C00B54A.JPG
174C824C18-DE63-4A29-9E0C-66FB7BED5304.JPG871A0279-8313-43F8-ABA4-AB5223B8249D.JPGxxx
181AAB6DE4-E94D-4DA1-867F-ED6E4A9D72F4.JPG185468B8-6C91-4103-865B-A04CEE0763F3.JPG4DB682A8-605A-4392-A010-9C1420D857FE.JPG923CDF7F-BF02-4CDB-ABE5-09B88834D97C.JPG8FCB2637-9C3B-4F82-B050-99D25D79ADD2.JPG
193922A2DA-3241-47FB-9FD5-48F6FF9A72CA.JPG38F83F03-8A2B-4D40-B9B7-4F11A64C824C.JPG99BE4BEE-4012-4E6E-A52E-5AF9ECC73B9A.JPGx2063FC25-85BE-4B77-8EC7-090FC4ED555A.JPG
2067491A17-95FE-488D-8A56-C5CFAB7BC7FD.JPG1A36F7C4-5C79-4584-8587-EB3BF19A675C.JPGxxx
21E379B031-6E4C-46A1-8BCC-6D7EB3703D07.JPG77C1EE6A-54CE-468D-97FE-093E3786A1E1.JPG41D27E8C-0FE5-43EB-8087-1E14418B6AA1.JPG56436D23-4C7E-4111-BFED-8D42CD1FD100.JPG135C3A4A-0B5B-4A25-9554-56D6BC038B5A.JPG
2261E4175E-67C1-4BC2-904D-927E8F3D9A34.JPG0A9B1ED1-6114-4F09-8A55-76ED5AC8F6B8.JPGB31037AC-EC2C-428E-AC28-2D917EEDDCB0.JPGxx
2366BE66F2-C526-489B-AFD8-AFFF18086296.JPGED034DC8-7A6A-4BB1-98FD-2B6FE3233F5B.JPG0A2972BF-78AE-4C50-9478-8955BFA74883.JPGB702D542-929F-458B-A170-4F3E10B17165.JPG94C8ACBA-0718-4C1D-8F83-19887C84E82F.JPG
24C354D848-4289-42D7-83F4-B7D0321E7985.JPG9AA6474E-B2B7-4951-B620-A0190EDF2BC3.JPG72610B79-FA9A-46B1-90DD-DCB434695EAA.JPG8DE4303A-7078-465A-B539-593CF1E9CF58.JPG836E8D91-C3D3-4EFC-BBF6-06A3E29A2E63.JPG
251E63AD95-7F47-4F5B-BFDE-C1BCFFC2E1D9.JPGFCADE45F-D08B-4FBC-BBE3-6584B3612F3E.JPGD689DF3F-D5E7-429A-ACD0-9579EE8B33EB.JPG1B735B0A-7509-4766-922C-A9811A389A2F.JPGB50A801C-C2A9-42F0-83E0-950FE9F65A1C.JPG
2662B09049-8588-4C74-A55E-93532060544F.JPG648ACC76-CB02-4BB2-BE27-7CCBAA25A516.JPGA0FDB17F-759D-4FC0-9B8D-FCC2981A1D9E.JPGxx
27478DA60C-69C6-4F02-BEFE-FD6B3712CCA8.JPGE3B1993B-1B53-4D39-BD4C-93576D51F7E0.JPGxxx
28BCFEF72C-2AA8-4AC0-AE44-E4DEF0E4D046.JPG4D4E2DF9-5442-4144-A501-9B1355C8B75E.JPGCDC7E7A6-4FE9-41C1-93F6-CAFB23FCF557.JPG0F5007FB-7A85-4481-82E8-4620F7A9B7EE.JPGDB1B7C5D-BC81-484B-8FBC-895E874834B0.JPG
291BF32C9B-69A4-4804-AC96-6E9D909791D0.JPG02711897-D3E8-4FDA-B62B-D6662525274E.JPG25223706-F9E4-4EE7-9E14-EFEAA5EC2160.JPG8A3C4E80-CBE1-4839-BB94-166A2E96102F.JPGx
30C4D39076-E0B5-4E99-987C-7D4CE17A69C8.JPG0E1F729A-A15A-4F4F-B694-9DCF2ABA4EBA.JPG770C590B-02E3-49CA-B791-F49AF58B2392.JPG9C97A060-9980-4A2E-870C-AAE96CD50163.JPG0147D5BC-77FB-4B29-A627-DA5225757346.JPG
3106C88026-735E-4967-A33B-6C9DE7D683C9.JPGC04458C1-1069-4432-9FAC-EB1B3E0911E6.JPG563DE267-7ED0-4C77-B6B0-C89C7A85227D.JPGC61A94F9-EA33-41E6-9619-66349A8ED349.JPG6F2ACC0A-89E1-495F-8F70-1EE5D7C833DC.JPG
327B8AFAC0-C917-4690-AFD4-7FABE99F1EFC.JPG9B439753-37B5-4701-90D9-123D4F539E36.JPGF6086FBA-29DA-427E-8DC9-F2B97C0F09C9.JPG0E3CBC16-FF92-476F-A62D-4EF95A5912E7.JPGx
337B066E11-8B23-45D2-A838-C5DCDDCEEDB5.JPGxxxx
3449D56F32-AE0D-43BE-AF46-E8BABE731640.JPGE201F749-986F-4FF4-8A12-505EDA23715A.JPGxxx
354F4E7F2C-CF3E-4CEA-A338-7D21C6AD20CF.JPGF80850E0-9637-44E7-9828-69ECC180265D.JPGEB02A602-920B-448F-89F6-2C06E01E9698.JPG01EBDB7F-CBCA-4EEB-BC0E-15FD81EFADD0.JPGC951E69B-6088-41F7-B1E1-B020AD110E9C.JPG
36B61C104B-E93F-4963-A8BF-BBE24FEA3AD2.JPG77A3CC77-9CDE-4E98-8E51-663EB83C0576.JPGxxx
37B2FD8B15-6CD4-47AC-936F-99DDA8C2C70D.JPGD63BDEC9-B1B2-4039-B846-5E0CC0B7DF6B.JPGDEDDB850-6F0A-4250-8AC8-B5D9DBF43EE2.JPG779FC469-FA2C-4729-94CD-7BE628DB3871.JPG4D4C011D-6A22-445D-A4D2-28C8238EC9D2.JPG
38C353C438-E0A3-4025-A465-5D60B8F79F64.JPG670D425A-9422-4668-BF60-9786C117FABA.JPG6E9AB0D3-84AB-4EE7-AD2B-F4CF384BF440.JPG7B577447-45A1-4161-9043-87C8A06FCF25.JPGx
3963D4A6CE-1FAE-4C59-85F2-7F73D277DB22.JPG5FC4C2F7-E06C-4038-B619-E1D1C14CEF5A.JPG5F985DF9-42B3-4AE1-8EA5-C794FAD39B4E.JPGxx
403FF82B75-B8D8-48CD-A013-7A28ABABA48C.JPG5028F616-04D5-465B-87D1-09C0F3D21045.JPGBCA8A367-D795-490D-AF8E-DDF185BB34A4.JPGC8C9DC3A-603E-4D6B-B22E-72CEE32A5E26.JPGDC7AF556-2C49-48B3-B5F7-85CF3C6DFE23.JPG
419739EF25-30F8-40DE-ABF9-03EC26C5D54E.JPG5A82900B-263C-41EF-8FEC-48D2F8ECB226.JPG10886283-F082-463D-B90D-96EC29247812.JPGxx
42D10DCDCA-030E-46DA-9106-B12C1C1C7CE6.JPG5CCAE27B-3229-4332-A123-D2259E1A3C92.JPGxxx
434B1D6288-BBE4-42C3-927B-41D4527E0F6C.JPGEDEF4064-5D0B-4450-B9D6-75850D493261.JPGxxx
4434EA03D3-E40F-40B0-B1CA-5CE2B27B1EAA.JPGCE7891FF-68F7-4BDD-AA90-55DB776B6C74.JPGxxx
4500673135-BBF4-4F85-A91D-1466939CCAC1.JPGED51D62D-DA91-4D68-B71D-F730AC435022.JPGxxx
46A0B2D543-2317-4969-A872-078DE73BE22A.JPG6D44E723-8A0F-494F-9DB9-CF8CA33A9AE7.JPG6445836C-3707-42E4-B16D-626F14540418.JPGA4C38BFC-44D5-44A7-9238-297151357844.JPGx
4775EFE073-4D03-4AB3-AE06-756A1DB371E7.JPG54956AEE-9509-41FD-BF07-8ED389373328.JPG605DE981-593B-4A5C-AAFC-5311777E4B62.JPG10553424-9844-472E-B219-8BEC9DF9B67A.JPG6534E968-4F5D-4994-B41B-F9279FBE8635.JPG
48C9FC74DE-15C2-4515-B762-1DAEBFD377EF.JPGDC6741C3-2A5F-4E64-9837-7AE3F2221D7A.JPG832E6A33-E1B6-4D6A-A061-6B7C10D5F38A.JPGxx
49940B99B8-C2FF-4CBB-8A8C-0CF17B868062.JPG90959F95-0076-40DD-964C-6F65072BE914.JPGF516E09B-1174-4A00-8642-3651C9A8EAA6.JPG893C271B-C903-4992-8A28-C1F7D6CB9F73.JPG52C73080-FF5A-4E19-88C5-9852A572C9EE.JPG
50CC3CC6AB-021C-4F1A-B0D1-A8B5C1FB60A3.JPG307E737E-5AB8-4871-A1EF-A97778666845.JPGxxx
510570D471-F6D7-40A0-9517-3CB8D67C76E2.JPGD447AF81-8B28-40B6-86F9-01F259625F73.JPG01DA22C3-A7EB-4D2B-8BC6-F72CF31F60B9.JPGxx
52637A335A-6DA8-4E23-8D84-26D84E8E6A86.JPG4D1AA064-A198-44DC-99B0-4F4AE5BD3B98.JPG237DAD00-9BB1-44A4-9E7C-19F7159C2FF2.JPGxx
53246E54EA-28A4-4C27-A1F3-D1B8C83F0CC3.JPG1E227540-E135-4742-8A85-A5465D6DB1ED.JPG78E2E2DF-9E28-46A9-95E0-1AC460E37ADD.JPG65253D66-18D2-4D8B-A5D4-9BFFC81FDF05.JPGBE51301A-A0E3-49A4-8EDA-BCA66D39589A.JPG
5489902B3D-D389-4B40-A6ED-17513AC23845.JPG8E303D32-30BB-4D41-AF55-BAB6E6EA25E9.JPG70BAA3C4-25A4-4812-873D-1886059922F6.JPG8071F810-B5F6-4C7A-AF0E-8D3AF54F86BE.JPG5E878532-C6E8-4043-B4EE-2F5A73138EAD.JPG
55FD9AB1B1-02D6-4F7D-800E-552BB9AEE216.JPG5DBD3AA4-A79C-4A90-9B16-035D881019E1.JPGF8313264-DCB9-44A6-A13A-8D71435B16CB.JPG799E7CCC-90CC-4275-A326-3D494EB48DA8.JPGx
56BA91EB1E-39B9-4EAF-A40E-FD8724A9C40B.JPG5ED01616-06CE-4465-8AB5-8EEC5723A134.JPG143339EA-8254-4D2A-A90B-D06A14DFF3E9.JPGD60C6299-8793-45E2-8B86-7C46D34FD9BA.JPG64B2B8D1-9BE4-49A6-94AA-536D5C0EB069.JPG
57B53CF497-0630-442E-A812-9C2EA2A9192A.JPG81272D9F-5C00-41C7-B6CA-7748C85E94E2.JPGAB11D98A-04A6-4C85-B4AF-7D4FD0402C17.JPGxx
58170654BB-C14C-4D76-AE4C-1D93DC1E295C.JPG6B5C9707-5010-427C-8179-2CB869A6F6B3.JPGD53F3687-6EBC-4B80-9193-4D909A91A582.JPGBFEDEF25-A1EB-42EA-A3E0-81DD8E55F9CE.JPG3543BAB9-AE12-4A69-9BDA-86F93827D4A0.JPG
59FA426F00-F10A-4B10-963F-5902E8711074.JPGE013E606-D17C-40FD-B66B-75E4A7F5D396.JPG1386C662-2712-445C-8007-3F3D28D27E2B.JPG29F90F2D-FB75-403E-BBB5-176599C82342.JPGBA1C5836-C73A-42BF-948F-B3170EBAEA12.JPG
60479FED94-FDAE-45C5-A17E-99BFE2CBEC10.JPG3C54E181-11AA-4258-A8C8-A66D9E9ED9FD.JPGED4BEF45-A53D-4B74-B91D-053087E8F4DE.JPGxx
61499E51FF-3B7A-4837-B5CA-9286350E2B7B.JPG29EB732E-4C6D-456E-A452-67C72AC5F799.JPGA0C119CB-5BB9-4A60-8B29-048842109F48.JPGC729BE2C-81C7-4F9A-8C78-173B037CF9C8.JPG57BED725-4A23-4EE6-96AE-7ACBEEDD0428.JPG
62299F87B2-2C1B-4D18-8413-3158B76681D5.JPGxxxx
63DDA9BCBB-804F-4EC8-9BB0-4A4C62AEE1B0.JPG05C5E960-0D0A-4FEC-9E08-29F4A66B34CB.JPG41285833-85B4-4143-8117-3504462B895D.JPG9E221F7F-1AE2-4032-B7B7-F1D3F5CBCA61.JPG764DA0CB-4ECA-42BC-8F2A-1C48AE9C496C.JPG
64BC025A79-5991-4EAD-90B8-D7B6312187AD.JPG8ECCFE3F-0245-4D1E-A6D8-1742CF73E363.JPGECE3C8DA-4490-42F0-9D8D-9249303FF83D.JPGxx
65FFD6BA0A-FC44-4B15-B6FE-9DBE5796D2F5.JPG1949754A-573D-47EE-99D8-0563AD02CF2D.JPG4A53C897-662A-4706-BFCC-34B858CFD7C5.JPGxx
666CF9FB2B-BD4D-4EF5-8A0D-723A65413CC3.JPG347D1A25-E7B2-412D-8FFD-3714E789931B.JPG3DF929DA-D990-4A6D-A176-9BC071247E96.JPGFD709699-A697-4AA1-BF1B-34C345168C6B.JPGDAC7D8AC-5C3A-46E5-A198-52259080A06A.JPG
67C126DA56-64D5-4172-A03B-B16D1F5C9DC9.JPG92DFB161-D05C-4AA0-9CA9-27CEB4BEB408.JPG0F9B11A5-8BA2-4F6B-ACCE-31015404DF11.JPGD4163735-5747-4274-946B-B36A34DCEEC3.JPGA8FA37B3-493E-4ACB-859D-94F26C1F22DF.JPG
683C3BFE91-C0E3-4628-A699-375734CF0442.JPG49C1F7FC-49D0-486C-A4AD-5C677E180929.JPGC8597CB8-14F4-4AFA-B42D-98DA8F9D5690.JPG2BC44CB2-566F-4506-82F7-E8E0DC0FD570.JPG6D855DF3-8197-4452-AB24-C455B24DC990.JPG
69F7EBCF10-8DAC-4F0B-96EE-9FE9C34DC018.JPG54697B4F-421A-4582-B33C-C552703D26D1.JPGCC0F1AA7-C8AD-4A38-9EDE-46CEA58AE96F.JPG087A9CAB-094D-4BCC-A445-9791FF426069.JPG8BC6F141-A090-42F8-B4A2-4D6CAE2FBB0B.JPG
7004417821-2A39-4C1B-B2E9-71A0DBFF3977.JPG1130C479-AE8F-421B-B754-C5E9392E38D2.JPGF166C813-091D-4919-AF04-71A0046F7C88.JPG9FD1FFD1-2021-4E32-A2F3-7A71893DAB2C.JPGx
718BB5E341-6CBE-4C48-A563-B8974D920BF8.JPGxxxx
72AF5C7EDF-A722-4B7B-9197-A4E34ED7326C.JPG79AC17BB-21D8-4222-A01B-590DBBBFAEEB.JPGxxx
733EC3D885-4157-4EB6-B5ED-7338DA4191AC.JPGC405BA32-D46A-4C0C-933A-7DE13D29A3A9.JPG2110F228-43B3-4E0C-B255-9CC11128C4DA.JPG832B1D8B-6576-4F9F-A7C9-97674043D544.JPGx
7447CD9778-76FE-4DBB-8A52-540E331D1FC3.JPGB6028B72-7633-40E5-8FD8-EE63DC3E9E47.JPGxxx
759CFFCCAD-EDB3-4D81-A355-6A2BF11A693D.JPG24025C85-A647-42FF-968C-DA3994ED5144.JPG38345B40-7B83-4BEE-83EA-C98802634DE8.JPGxx
76CB8401C9-33F4-4406-8702-3D01EA649915.JPGA12AC946-2451-4B82-8D77-7002A1C3F13F.JPGA9223FBE-0004-4382-AB4B-C7A889B52210.JPGC20C0273-C38D-4BF0-A4AD-D0AA6198441B.JPG80850AA7-E0B5-4AD4-99FB-0D324542F900.JPG
77433AF59C-1807-4536-9472-23412FDDFD4F.JPG5F82F8A8-C6B6-4285-8655-3FEC9154D926.JPGD91B6C4B-CBC3-4F84-B704-3EBEDDBB02F1.JPGxx
CST Observations 2301
 
Upvote 0
It looks like the data is in column J, yet you are using column I to find the last row:
Rich (BB code):
    last_row = Sheets(1).Range("I150").End(xlUp).Row

Could that be your issue?
You didn't include column I in your screen print, so I cannot tell what may be in it.
 
Upvote 0
It looks like the data is in column J, yet you are using column I to find the last row:
Rich (BB code):
    last_row = Sheets(1).Range("I150").End(xlUp).Row

Could that be your issue?
You didn't include column I in your screen print, so I cannot tell what may be in it.
So in the original code
last_row = Sheets(1).Range("I654").End(xlUp).Row
I shorten up the Range to I150 to try and tidy up the code. It did not have to read as many rows and posable less errors.
I did put it back but it still ran only to row 10. I thought it might be that too.
If the code is in the original Excel workbook it works fine, as you saw.
But in any other it does not.
 
Upvote 0
I don't like to hard-code the row number in there like that. You can dynamically find the last row like this:
VBA Code:
last_row = Sheets(1).Cells(Rows.Count,"I").End(xlUp).Row

But the point of my last post was that you are looking at column I to determine where the last row is.
Should you be looking at column I or column J?
Since in your last post, you did not show us what is in column I, I cannot tell whether it is feasible to use this or not.

Typically, if you are looping through column J, like you are doing here:
Rich (BB code):
       Do While Sheets(1).Cells(last_row, 10) = 0
you would want to find the last row with data in that same column (J), not column I.
 
Upvote 0
I don't like to hard-code the row number in there like that. You can dynamically find the last row like this:
VBA Code:
last_row = Sheets(1).Cells(Rows.Count,"I").End(xlUp).Row

But the point of my last post was that you are looking at column I to determine where the last row is.
Should you be looking at column I or column J?
Since in your last post, you did not show us what is in column I, I cannot tell whether it is feasible to use this or not.

Typically, if you are looping through column J, like you are doing here:
Rich (BB code):
       Do While Sheets(1).Cells(last_row, 10) = 0
you would want to find the last row with data in that same column (J), not column I.
First, C&H is my all time favor comic strip. Own all the books.
Second, In this case column I has no useable data. It was just names. So I did not include it. I didn't think it mattered if there was any data in it or not. Either way it would just loop until row 150.
Third, I changed .Rang("I150) to "J150. Still only inserted pictures to row 10.
 

Attachments

  • Row 10 Pic.jpg
    Row 10 Pic.jpg
    40.7 KB · Views: 24
Upvote 0
I do not have pictures to insert, so cannot test that part. I simply had it updating the cells with some text to see if I could see what is going on, if there was a problem with the loop.
It seems to go through and update all rows (up to the 77 you listed for me without issue).

So, a few things which could be going on:

1. Maybe it is crashing out because there is too much memory being added by adding all these pictures to the worksheet. Are you getting some sort of error, or is it just stopping?
One thing you could do is add this line to your code, just before the "End Sub" line:
VBA Code:
MsgBox "Macro Complete!"
If, when you run the code, you get this Message Box pop-up, that is telling you that it thinks it did everything and finished without issues.
If you do NOT get this Message Box pop-up, then it means that your code is probably crashing. Are you getting any sort of error message? If so, what does it say?

2. Another thing to check is the first image that is NOT being populated. Make sure that there isn't an error with that reference or that particular image.
 
Upvote 0

Forum statistics

Threads
1,223,608
Messages
6,173,325
Members
452,510
Latest member
RCan29

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