+ Reply to Thread
Results 1 to 67 of 67

VBA to show picture in picturebox by filepath in cell

  1. #1
    Registered User
    Join Date
    04-24-2015
    Location
    Leiden
    MS-Off Ver
    2013
    Posts
    13

    VBA to show picture in picturebox by filepath in cell

    Hi,

    I am trying to have a picture in a imagebox(image1). The picture is , let's say, in folder C:/folder.
    The full path (eg C:/folder/picture.jpg) is displayed in a cell(the imagebox(image1) is positioned over the cell). the cell is B7.

    I am using vlookup and a dropdown(on another sheet in the same file) to change the filepath displayed in cell B7.

    I can't seem to get the code right to get excel to show my picture from the displayed path in the imagebox(image1) and to chenge the picture when the filepath displayed in that cell changes.



    Could be done just by vlookup and linked image, I know. But this would make my file larger. The file will be copied to the server at least 10x a day...


    If anyone could help me code this I would be very grateful!

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    You can do what you want using the worksheet's change event.

    For the sheet with the dropdown.

    1) Copy the first block of code below.
    2) Right-Click the sheet tab of interest.
    3) Select "View Code"
    4) Paste the code into the window that appears.
    5) Save the file as a macro-enabled .xlsm file.
    6) Change the $J$3 to the $$ address of the cell you are using for the dropdown.
    Change Sheet1 to the name of the sheet with cell B7 and the picture. Delete the original picture off that sheet, too.

    More information on events and event code is available here:

    Explanation of events in Excel

    Please Login or Register  to view this content.
    Then, in a regular codemodule, use this code:

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    04-24-2015
    Location
    Leiden
    MS-Off Ver
    2013
    Posts
    13

    Re: VBA to show picture in picturebox by filepath in cell

    Thanks sooo much! This works exactly as I want it to!

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    Great! Thanks for letting me know, and for the rep.

  5. #5
    Registered User
    Join Date
    04-24-2015
    Location
    Leiden
    MS-Off Ver
    2013
    Posts
    13

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,

    One last question if I may....

    I am implementing your code(that works very well in my testfile) into the originally intended xlsm. But now I keep getting 1004 errors and I cant figure out why...
    This is what I do:


    Please Login or Register  to view this content.
    in sheet1 with the dropdown(cell C8)
    and

    Please Login or Register  to view this content.
    in a module.

    When I run debug it marks this line, yet it all worked fine in the test file....
    Please Login or Register  to view this content.
    Have I changed the code in a way it isnt supposed to be changed?

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    Try using this version to debug - it checks that the sheet is not protected and that the file exists.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-24-2015
    Location
    Leiden
    MS-Off Ver
    2013
    Posts
    13

    Re: VBA to show picture in picturebox by filepath in cell

    works like a charm!!
    thanks again!

  8. #8
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hello,

    I am currently have a userform that have a textbox field, a search command button, and an image1. I am trying to find code to so that I can search for a file name (the picture name should be written in textbox) from a file on the computer of an image that will then cause that image to come up in the image1 once the command button is clicked and if the name not if the name not exist a message box should appear "File not exist". I am a novice at VBA/Macro. The images are all located on the C drive. Any help would be greatly appreciated.

    Thanks,

  9. #9
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    This shows how to load a picture into an image control - I'm just not sure what you mean by search for a filename - the user can search for the file using the GetOpenFileName method, or you can search specific folders for a wildcard match - but you may want to specify the folders....

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,

    Thanks for your help.

    But what I need is a Code to open various Pictures from the folder (the folder is called “images”).
    When I write the name of the picture in the textbox and click the button, the picture loads directly in image1 and if the picture name is not found in the folder then the message box should appear.

    Thanks again

  11. #11
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    Why not use the dialog to select the file instead?

    Otherwise, try this after correcting the path to the folder images (in both places). Note that it will pick the first matching file, which may not be the one you want

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    it works wonderful,
    thanks a lot

  13. #13
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hello,

    I am trying to create a filter with combobox, for example if I select the name ”John” in the fist combobox, then all the person and information with the name John are presented in the Listbox(Name ,Age, Length) and if I select the first name the result in listbox should be filtered etc..

    Your help would be greatly appreciated.

    Thanks
    exceltable.JPGuserform.JPG

  14. #14
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    Not sure of your naming convention for the listbox and your comboboxes, but use code like this to populate the comboboxes with unique values, and change the listbox when the combobox changes.

    Please Login or Register  to view this content.
    Last edited by Bernie Deitrick; 09-08-2015 at 12:18 PM.

  15. #15
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: Filter with combobox VBA

    Hi Bernie,

    Thanks for your help.
    I keep getting errors when I select the name for example”John” in the first combobox

    Thanks again
    Attached Files Attached Files

  16. #16
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: Filter with combobox VBA

    Sorry - I did not copy the dim statement at the top, which declared the sh object. Here is a better version, in the file.


    Filtercombobox.xlsm
    Last edited by Bernie Deitrick; 09-09-2015 at 09:55 AM.

  17. #17
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,
    Thanks again for your help.
    The extraction or the filtering, works only with Combobox 1,but the ComboBox 2 till ComboBox 6 do not sub filtering.

    For example when I select the ComboBox 1 “John” as first name, I get in Listbox all the Person with first name “John “ but
    when select the last name in Combobox 2 “Smith” the filtering is not working.
    Normally the ListBox should be filtered for “John Smith”.
    What I mean, I select the combobox 2 for filtering the combobox 1 or when I select Combobox 3 then the first both ComboBoxes
    should be filtered etc. So the one filters the other.

    Thanks,
    Attached Files Attached Files

  18. #18
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    Every time you select a value, you need to reset the combobox options, along the lines of the code in this workbook

    Filter combo box.xlsm

  19. #19
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,

    the Combobox filter works, but when I select the ComboBox 1 “John” and then in Combobox 2 the Last name “Smith” the Userform hangs.
    I can´t figure out why...
    Thanks,
    Attached Files Attached Files

  20. #20
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    Try this one - the code did not like when the overall list was filtered to just one value.

    Filter combo box 2.xlsm

  21. #21
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,

    the filtering works wonderful , but when I write in Combobox a name is not exist in the excel sheet I get an error “1004” .

    Thanks a lot!

  22. #22
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    The comboboxes list all the available valid values - just change the style property of the comboboxes to fmStyleDropDownList, and you will only be able to select valid values from the list, and you will not get that error.

  23. #23
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,

    I changed it, as you told me and now it works without error.

    Thank you very much

  24. #24
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,

    I want ask you if it is possible to open various PDF File in UserForm from the folder .(the folder is called “PDF”).

    Thanks again

  25. #25
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    Open the file in Adobe (or other) reader, or show the file in your userform?

  26. #26
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,

    to show the file in userform.

  27. #27
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    You can show a saved screen capture (jpeg file) of the PDF as a picture, or open the PDF using the default reader, but you would need another non-standard control to open the file directly in the userform.

  28. #28
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    the opening of PDF using the default reader is it complecated or not? and how does it work?

  29. #29
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    Well, this will do it with Adobe Acrobat Reader - check your folder path, and change the setting under security (enhanced) by unchecking "Enable protected mode at startup"

    Please Login or Register  to view this content.

  30. #30
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,

    at first I want to write the name of PDF file in the textbox1 and when I click the CommandButton1, the PDF should open .

  31. #31
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    Use something like this in the click event of command button

    Please Login or Register  to view this content.

  32. #32
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    I used the code but when I click the button I get an error .
    Attached Files Attached Files

  33. #33
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    This needs to point to an executable file that can accept a file name as a passed parameter:

    Please Login or Register  to view this content.
    what I had:

    Please Login or Register  to view this content.

  34. #34
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,
    I change it, but when I write the name of PDF file in textbox and click the button, I still get an error “53” file not Found.
    Attached Files Attached Files

  35. #35
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    Your myPath was messed up, and you need to change C:\Path\ to the actual path of the folder with the pdf files:

    Please Login or Register  to view this content.

  36. #36
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    I change it,to: myfile = "C:\Users\RUDI\Desktop\PDF\" & Me.TextBox1.Text

    but I still get an error “53” file not Found.

  37. #37
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    You need to change this setting of your Reader:

    Edit / Preferences / Security (Advanced) / UNcheck "Enable protected mode at startup"

  38. #38
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,

    I changed the setting but I still get an error “53” file not Found.
    UNcheck.JPGcode.JPG

  39. #39
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    Is the path to your file AcroRd32 actually in English? Run this macro:

    Please Login or Register  to view this content.
    If the message box is empty instead of "AcroRd32.exe" then find the file and copy the path, then modify the myPath variable's assignment to match your actual path.

  40. #40
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    the message box is empty.
    waht you mean with "find the file and copy the path, then modify the myPath variable's assignment to match your actual path. "

  41. #41
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    I mean find the file AcroRd32.exe where it resides on your computer, and copy the path. Hold down the windows key and press F, then type AcroRd32 and your system should find it. Right click on the file and choose "Properties" then copy the location string and use that in the code. It may not even be named that on non-English systems, so you may need to do some research.

  42. #42
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    I found the location and I puted in myPath = " C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe" but it not working
    Properties.JPG
    Attached Images Attached Images

  43. #43
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    I mean that the PDF is opened but he kann not find the File.
    error.JPG

  44. #44
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    Make sure that you are entering the entire file name, including the extension.

  45. #45
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,

    it works with extension (File name.PDF), is it not another way to work without extension(.PDF)?

    thanks again

  46. #46
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    Change the line that ends


    ........ & Me.TextBox1.Text

    to

    ........ & Me.TextBox1.Text & ".PDF"

    and you will not have to type the file extension

  47. #47
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,

    and thank you very much.

  48. #48
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,

    I have the following excel userform "Data" and I want to extend the number of column in the listbox. I used this code:
    Me.lsbSheet1.ColumnCount = 21
    lsbSheet1.ColumnWidths = "30;40;30;30;50;70;70;70;70;70;70;;50;50;50;50"

    But it did not work.

    I am grateful in Advance for your help.
    Attached Files Attached Files

  49. #49
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    You need to include units:

    Please Login or Register  to view this content.

  50. #50
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,

    I changed the code but I still have 10 column in listbox.
    listbox.JPG
    Attached Files Attached Files

  51. #51
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    You have based all your arrays on this array:

    arrSheet1 = .Range(.Cells(2, 1), .Cells(2 + lngNumber - 1, 11)).Value

    Which has 11 columns (but you see 10 because one has 0 width). So change the 11 to 21.

  52. #52
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Thank you Bernie.

  53. #53
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hello Bernie,

    I create a search button with textbox, for example if I write the number in the Textbox and click on button the data should appear in the other textboxes.
    The search button is not working because I get error when I click on button.I am grateful if you check up the codes of searchform.xlsmsearch button and find the error.
    Your help would be greatly appreciated.

    Thankssearchbutton.JPG

  54. #54
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    Try it like this:

    searchform.xlsm

  55. #55
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Thank you very much Bernie.
    That is what I need

  56. #56
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hello Bernie,
    I need your help with the search form, because I get “Error” when I select the Comboboxes, that happens when I insert two additional Combo Boxes to the search form.
    The error appear for example when I selected: the first name : John, last name :smith ,the age:25, the length: 180 and the weight :80
    Thanks in advance.
    Attached Files Attached Files

  57. #57
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hello Bernie,
    do you found what could be the reason of the error?
    Thanks in advance.

  58. #58
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hello,

    I have a listbox in a userform with several columns.
    I’m trying to set up a code for transfer button, which allow me to copy the selected rows in a listbox and to past them in the excel sheet.
    With the following code I can transfer all the rows in listbox, but I want to transfer only the selected rows. For example I highlight the first rows and click the transfer button to copy the rows in the excel sheet "results" and then the second row etc..

    Any help will be grateful

    Thank you in advance
    Please Login or Register  to view this content.

  59. #59
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: VBA to show picture in picturebox by filepath in cell

    Why not do this?

    Please Login or Register  to view this content.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  60. #60
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi JapanDave,
    I thank you for the quick reply.
    I used the code but when I click the button I get an error .

    thanks
    searchform2.xlsm

  61. #61
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    Use the Selected property, like below, and you can loop through the columns:

    Please Login or Register  to view this content.

  62. #62
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,

    I thank you for the quick reply.
    I used the code for the transfer button but I get an error in the following line .
    Please Login or Register  to view this content.
    thanks

  63. #63
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    I was just using your code (ListBox1.Column(j, i)), which needs list instead of column:

    Please Login or Register  to view this content.

  64. #64
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: VBA to show picture in picturebox by filepath in cell

    Quote Originally Posted by Hilfesucher View Post
    Hi JapanDave,
    I thank you for the quick reply.
    I used the code but when I click the button I get an error .

    thanks
    Attachment 437250
    Your code throws the same error and it is b/c you don't have a value in the other columns of listbox1. You need error handlers or use code that will avoid errors.

  65. #65
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,

    I changed the setting but I get the results not properly.
    thanks
    transfer.JPG

  66. #66
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to show picture in picturebox by filepath in cell

    Could you show what you have in the listbox, and how you want them arranged on the sheet? I think you may want them to be transposed, but I can't be sure until you show what you want.

  67. #67
    Registered User
    Join Date
    04-21-2015
    Location
    Köln,Germany
    MS-Off Ver
    2010
    Posts
    40

    Re: VBA to show picture in picturebox by filepath in cell

    Hi Bernie,

    Thank you for your help.
    I found the solution for the Transfer button, but now I have Problem with the filtration.
    I have 5 comboboxes for the filtration.
    When I select the comboboxes from 1 to 4, I do not have any problem but when I select the 5 Combobox I get the result vertically. That happens only when I have one row ( one result) in Listbox.
    My question is: how can I get the last result horizontally?
    For example: I select the first name "John", Last name "Smith", country "United states" and for B length "R" but when I select for C weight " E or R " I get horizontally result.
    Any help will be appreciated.

    Thank you again.

    filteration.JPG

    searchform_ge.xlsmsearchform_ge.xlsm

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Show picture by clicking on a cell
    By ossa in forum Excel General
    Replies: 13
    Last Post: 05-13-2015, 10:49 AM
  2. [SOLVED] Show picture of cell in Userform
    By bullshot25 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-09-2014, 04:06 AM
  3. [SOLVED] Copying files from a selected filepath to a filepath mentioned in a worksheet's cell
    By subbby in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-10-2012, 03:59 PM
  4. If cell value greater than X, show picture
    By Artiso in forum Excel General
    Replies: 2
    Last Post: 11-05-2011, 03:38 PM
  5. [SOLVED] How do I show the current Excel filepath in the toolbar line?
    By Rick3789 in forum Excel General
    Replies: 3
    Last Post: 03-09-2006, 02:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1