Insert images from Directory using Excel2019 Community Moderator ElectionHow to create Excel (.XLS and .XLSX) file in C# without installing Ms Office?Create an automatic date stamp in excel from an entryrun-time error '13': type mismatch VBA 2010 to ensure uppercase text in cellExcel VBA URLDownloadToFile Error for HTTPSresourceExcel VBA Change From email address with IBM Notes?excel on change not working if cell value is changed by another moduleLoop doesn't work when I call it in Private Sub ChangeUsing Autofill in Excel with Protected cellsvisual basic procedure too large error & ambiguous name detected worksheet_changeUse excel-VBA to colour a cell if a certain number is placed

If there are any 3nion, 5nion, 7nion, 9nion, 10nion, etc.

"seeing as you don't know anyone but me" meaning in this context

Correct physics behind the colors on CD (compact disc)?

I encountered my boss during an on-site interview at another company. Should I bring it up when seeing him next time?

How can neutral atoms have exactly zero electric field when there is a difference in the positions of the charges?

How do you say “my friend is throwing a party, do you wanna come?” in german

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

Make me a metasequence

Formatting a table to look nice

Relationship between the symmetry number of a molecule as used in rotational spectroscopy and point group

Lock enemy's y-axis when using Vector3.MoveTowards to follow the player

Why is it "take a leak?"

Why won't the strings command stop?

Plagiarism of code by other PhD student

Was it really inappropriate to write a pull request for the company I interviewed with?

Where is the fallacy here?

Would the melodic leap of the opening phrase of Mozart's K545 be considered dissonant?

How to mitigate "bandwagon attacking" from players?

Is divide-by-zero a security vulnerability?

Being asked to review a paper in conference one has submitted to

The need of reserving one's ability in job interviews

1970s scifi/horror novel where protagonist is used by a crablike creature to feed its larvae, goes mad, and is defeated by retraumatising him

Specific Chinese carabiner QA?

Why is my Contribution Detail Report (native CiviCRM Core report) not accurate?



Insert images from Directory using Excel



2019 Community Moderator ElectionHow to create Excel (.XLS and .XLSX) file in C# without installing Ms Office?Create an automatic date stamp in excel from an entryrun-time error '13': type mismatch VBA 2010 to ensure uppercase text in cellExcel VBA URLDownloadToFile Error for HTTPSresourceExcel VBA Change From email address with IBM Notes?excel on change not working if cell value is changed by another moduleLoop doesn't work when I call it in Private Sub ChangeUsing Autofill in Excel with Protected cellsvisual basic procedure too large error & ambiguous name detected worksheet_changeUse excel-VBA to colour a cell if a certain number is placed










0















I want to insert images from a folder based on what is written in a cell



Example



Cell A1 has the word "ABC001"



I want cell B1 to insert the image from a directory - image name = "ABC001.JPG"



I have found some VBA code that does this for me, but this only works on one cell.
i would like it to work on the entire column



Private Sub Worksheet_Change(ByVal Target As Range)

Dim myPict As Picture
Dim PictureLoc As String

If Target.Address = Range("A2").Address Then

ActiveSheet.Pictures.Delete

PictureLoc = "\ca-sbs-01tSharedExcelImages" & Range("A2").Value & ".jpg"

With Range("B2")
Set myPict = ActiveSheet.Pictures.Insert(PictureLoc)
RowHeight = myPict.Height

myPict.Top = .Top
myPict.Left = .Left
myPict.Placement = xlMoveAndSize
End With

End If

End Sub









share|improve this question
























  • I recommend you using Dir(Path) to get the exact filename and some If to handle an error that would happen if it wasn't there. As for doing for the whole column you could use a loop to get the job done.

    – Damian
    12 hours ago
















0















I want to insert images from a folder based on what is written in a cell



Example



Cell A1 has the word "ABC001"



I want cell B1 to insert the image from a directory - image name = "ABC001.JPG"



I have found some VBA code that does this for me, but this only works on one cell.
i would like it to work on the entire column



Private Sub Worksheet_Change(ByVal Target As Range)

Dim myPict As Picture
Dim PictureLoc As String

If Target.Address = Range("A2").Address Then

ActiveSheet.Pictures.Delete

PictureLoc = "\ca-sbs-01tSharedExcelImages" & Range("A2").Value & ".jpg"

With Range("B2")
Set myPict = ActiveSheet.Pictures.Insert(PictureLoc)
RowHeight = myPict.Height

myPict.Top = .Top
myPict.Left = .Left
myPict.Placement = xlMoveAndSize
End With

End If

End Sub









share|improve this question
























  • I recommend you using Dir(Path) to get the exact filename and some If to handle an error that would happen if it wasn't there. As for doing for the whole column you could use a loop to get the job done.

    – Damian
    12 hours ago














0












0








0








I want to insert images from a folder based on what is written in a cell



Example



Cell A1 has the word "ABC001"



I want cell B1 to insert the image from a directory - image name = "ABC001.JPG"



I have found some VBA code that does this for me, but this only works on one cell.
i would like it to work on the entire column



Private Sub Worksheet_Change(ByVal Target As Range)

Dim myPict As Picture
Dim PictureLoc As String

If Target.Address = Range("A2").Address Then

ActiveSheet.Pictures.Delete

PictureLoc = "\ca-sbs-01tSharedExcelImages" & Range("A2").Value & ".jpg"

With Range("B2")
Set myPict = ActiveSheet.Pictures.Insert(PictureLoc)
RowHeight = myPict.Height

myPict.Top = .Top
myPict.Left = .Left
myPict.Placement = xlMoveAndSize
End With

End If

End Sub









share|improve this question
















I want to insert images from a folder based on what is written in a cell



Example



Cell A1 has the word "ABC001"



I want cell B1 to insert the image from a directory - image name = "ABC001.JPG"



I have found some VBA code that does this for me, but this only works on one cell.
i would like it to work on the entire column



Private Sub Worksheet_Change(ByVal Target As Range)

Dim myPict As Picture
Dim PictureLoc As String

If Target.Address = Range("A2").Address Then

ActiveSheet.Pictures.Delete

PictureLoc = "\ca-sbs-01tSharedExcelImages" & Range("A2").Value & ".jpg"

With Range("B2")
Set myPict = ActiveSheet.Pictures.Insert(PictureLoc)
RowHeight = myPict.Height

myPict.Top = .Top
myPict.Left = .Left
myPict.Placement = xlMoveAndSize
End With

End If

End Sub






excel vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 11 hours ago









Pᴇʜ

23.6k62952




23.6k62952










asked 12 hours ago









FabioFabio

235




235












  • I recommend you using Dir(Path) to get the exact filename and some If to handle an error that would happen if it wasn't there. As for doing for the whole column you could use a loop to get the job done.

    – Damian
    12 hours ago


















  • I recommend you using Dir(Path) to get the exact filename and some If to handle an error that would happen if it wasn't there. As for doing for the whole column you could use a loop to get the job done.

    – Damian
    12 hours ago

















I recommend you using Dir(Path) to get the exact filename and some If to handle an error that would happen if it wasn't there. As for doing for the whole column you could use a loop to get the job done.

– Damian
12 hours ago






I recommend you using Dir(Path) to get the exact filename and some If to handle an error that would happen if it wasn't there. As for doing for the whole column you could use a loop to get the job done.

– Damian
12 hours ago













1 Answer
1






active

oldest

votes


















0














Maybe you are after this



Private Sub Worksheet_Change(ByVal Target As Range)

Dim myPict As Picture
Dim PictureLoc As String

On Error GoTo EH
Application.EnableEvents = False
If Target.Column = 1 Then

'Pictures.Delete

PictureLoc = "\ca-sbs-01tSharedExcelImages" & Target.Value2 & ".jpg"


With Target.Offset(, 1)
Set myPict = ActiveSheet.Pictures.Insert(PictureLoc)
.RowHeight = myPict.Height
myPict.Top = .Top
myPict.Left = .Left
myPict.Placement = xlMoveAndSize
End With

End If
EH:
Application.EnableEvents = True
End Sub





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55021303%2finsert-images-from-directory-using-excel%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Maybe you are after this



    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim myPict As Picture
    Dim PictureLoc As String

    On Error GoTo EH
    Application.EnableEvents = False
    If Target.Column = 1 Then

    'Pictures.Delete

    PictureLoc = "\ca-sbs-01tSharedExcelImages" & Target.Value2 & ".jpg"


    With Target.Offset(, 1)
    Set myPict = ActiveSheet.Pictures.Insert(PictureLoc)
    .RowHeight = myPict.Height
    myPict.Top = .Top
    myPict.Left = .Left
    myPict.Placement = xlMoveAndSize
    End With

    End If
    EH:
    Application.EnableEvents = True
    End Sub





    share|improve this answer



























      0














      Maybe you are after this



      Private Sub Worksheet_Change(ByVal Target As Range)

      Dim myPict As Picture
      Dim PictureLoc As String

      On Error GoTo EH
      Application.EnableEvents = False
      If Target.Column = 1 Then

      'Pictures.Delete

      PictureLoc = "\ca-sbs-01tSharedExcelImages" & Target.Value2 & ".jpg"


      With Target.Offset(, 1)
      Set myPict = ActiveSheet.Pictures.Insert(PictureLoc)
      .RowHeight = myPict.Height
      myPict.Top = .Top
      myPict.Left = .Left
      myPict.Placement = xlMoveAndSize
      End With

      End If
      EH:
      Application.EnableEvents = True
      End Sub





      share|improve this answer

























        0












        0








        0







        Maybe you are after this



        Private Sub Worksheet_Change(ByVal Target As Range)

        Dim myPict As Picture
        Dim PictureLoc As String

        On Error GoTo EH
        Application.EnableEvents = False
        If Target.Column = 1 Then

        'Pictures.Delete

        PictureLoc = "\ca-sbs-01tSharedExcelImages" & Target.Value2 & ".jpg"


        With Target.Offset(, 1)
        Set myPict = ActiveSheet.Pictures.Insert(PictureLoc)
        .RowHeight = myPict.Height
        myPict.Top = .Top
        myPict.Left = .Left
        myPict.Placement = xlMoveAndSize
        End With

        End If
        EH:
        Application.EnableEvents = True
        End Sub





        share|improve this answer













        Maybe you are after this



        Private Sub Worksheet_Change(ByVal Target As Range)

        Dim myPict As Picture
        Dim PictureLoc As String

        On Error GoTo EH
        Application.EnableEvents = False
        If Target.Column = 1 Then

        'Pictures.Delete

        PictureLoc = "\ca-sbs-01tSharedExcelImages" & Target.Value2 & ".jpg"


        With Target.Offset(, 1)
        Set myPict = ActiveSheet.Pictures.Insert(PictureLoc)
        .RowHeight = myPict.Height
        myPict.Top = .Top
        myPict.Left = .Left
        myPict.Placement = xlMoveAndSize
        End With

        End If
        EH:
        Application.EnableEvents = True
        End Sub






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 12 hours ago









        StoraxStorax

        4,2583519




        4,2583519





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55021303%2finsert-images-from-directory-using-excel%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

            Алба-Юлія

            Захаров Федір Захарович