Consulting

Results 1 to 13 of 13

Thread: Excel VBA IMAGE help!

  1. #1

    Excel VBA IMAGE help!

    Hi All,
    I would like to get your help on Excel and VBA.


    I have attached my excel sheet with this message

    My task to do is:
    I would like to create VBA interface like this image attached which is when I see image on the screen and click on accept molecule it should go to one excel sheet, and when I click on rejected molecule button it should go to other.

    If I can get an undo would be useful too

    Kindly help !
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    VBAX Regular
    Joined
    Jan 2018
    Location
    The Netherlands
    Posts
    45
    Location

    You must think of this

    Quote Originally Posted by jayadeepa View Post
    Hi All,
    I would like to get your help on Excel and VBA.


    I have attached my excel sheet with this message

    My task to do is:
    I would like to create VBA interface like this image attached which is when I see image on the screen and click on accept molecule it should go to one excel sheet, and when I click on rejected molecule button it should go to other.

    If I can get an undo would be useful too

    Kindly help !
    I like to inform you that When you put more images on a worksheet, your program grows very iT is a better way to use links who load the images When you open the sheet.

    regards

    Hightree

  3. #3

    Smile New to vba

    I’m new to to Vb any info regarding this will be useful.
    thanks
    Last edited by jayadeepa; 01-13-2018 at 05:42 AM.

  4. #4
    VBAX Expert
    Joined
    May 2016
    Posts
    604
    Location
    I don't understand what you main requirement is but I can tell you how to do a "Back" button which will always take you to the previous sheet you had active:
    In every worksheet put the followning code:

    Private Sub Worksheet_Activate()
        ActiveWorkbook.Names.Add Name:="prevsheet", RefersTo:=ActiveWorkbook.Names("currsheet")
        ActiveWorkbook.Names.Add Name:="currsheet", RefersTo:=ActiveSheet.Name
    end sub
    then you can put " back" buttons wherever you like ( every sheet if required) and run this code from the buttons:


    sub Goback ()
    Dim str As String
    Dim Lent As Integer
    
    
     str = (ActiveWorkbook.Names("prevsheet"))
     Lent = Len(str)
     str = Mid(str, 3, Lent - 3)
    Worksheets(str).Activate
    
    
    End Sub

  5. #5
    Hi,
    My main requirement is by selecting a image if I click on the command button A that row should go to Sheet1, If I click on command button B that row should move to Sheet2.
    Thanks much

  6. #6
    VBAX Expert
    Joined
    May 2016
    Posts
    604
    Location
    I click on the command button A that row should go to Sheet1
    What do you mean by this? do you mean that this entire row should be copied to sheet2, if so where on sheet 2, or do you mean this row should be moved to sheet 2 ie. deleted from this sheet if so what do I do with the other rows on this sheet? and also where on sheet 2. THAT is what I mean about "I don't undertand your requirements"

  7. #7
    Hi,
    I'm a chemist.
    All I need to do is,
    If I see an image in Sheet1 if I like it I will click on Command Button A and that particular image and its row will be moved to Sheet2 (anywhere).
    If suppose,If I see an image in Sheet1 If I didn't like that molecule I will click on Command Button B and that particular image and its row will be moved to Sheet3 (anywhere).
    Thus, I will do this for all the rows.

    Thanks
    Last edited by jayadeepa; 01-13-2018 at 09:58 AM.

  8. #8
    VBAX Expert
    Joined
    May 2016
    Posts
    604
    Location
    I still not quite sure what you want, but this code will copy the row of the active cell to sheet2, so run this code on the "like it" button and change the sheet number for the Unlike it button;

    Sub movedata()
     With Worksheets("sheet2")
      nextrow = 1 + .Cells(Rows.Count, "F").End(xlUp).Row
     End With
     ActiveCell.EntireRow.Copy Destination:=Worksheets("sheet2").Range("A" & nextrow)
    
    
    
    
    End Sub

  9. #9
    I have more than 50 columns. A:CG
    A column has the molecule image.If I like it I will click on Command Button A and that particular image and its row will be moved to Sheet2 (anywhere).
    If suppose,If I didn't like that molecule I will click on Command Button B and that particular image and its row will be moved to Sheet3 (anywhere). Not change the Sheet Name. I want to THE CORRESPONDING row to move it.
    All I want to do this in VB Thus, I will do this for all the rows.
    A:CG contains the data to be moved.


    Any ideas?VBA.jpgUntitled.png

  10. #10
    VBAX Expert
    Joined
    May 2016
    Posts
    604
    Location
    If the link to your image is on the same row that you have got selected then my code will do this for you, except it doens't delete the row in the active sheet. Have you tried it?
    You still not being specific about your requirements because you attached a snapshot of a userform but no details about it at all. How I am supposed to guess what you are trying to do.

  11. #11
    Hi ,
    I executed the code, it works.. But the rows were starting from 13th row. Is there any way that it should start with 1st row.?
    Also is there any possiblity that I can integrate userform vs excel sheet, my images will be listed and from that I click on accept button and the corresponding rows are copied !
    Thank you so much....Attachment 21344Attachment 21344

  12. #12
    VBAX Expert
    Joined
    May 2016
    Posts
    604
    Location
    this is exactly what I mean about "I do not understand your requirement" Actually what I am really saying is that you have missed out lots of details about your requirements, so I have to guess:
    If I see an image in Sheet1 if I like it I will click on Command Button A and that particular image and its row will be moved to Sheet2 (anywhere).
    you quite clearly say "anywhere" in your requirements. Unfortunately anywhere doesn't exist in programming I have to put it somewhere so I made a decision to put it in the next blank line:
    this code detects which is the next blank line in sheet2

    With Worksheets("sheet2") 
            nextrow = 1 + .Cells(Rows.Count, "F").End(xlUp).Row 
        End With
    you now state:
    Is there any way that it should start with 1st row.?
    So you can change my macro so that it always writes into row 1 very easily
    just change the code above to :
    nextrow=1
    however I don't believe this is what you want to do ( because it doesn't make sense) , because this will copy the data into row1 when the button is first clicked, and the second time it is clicked and the third etc, so it will alway copy it into row 1.

    If you delete all the data in sheet 2 it will start writing into row 1, and then each additional click will copy to the next blank row, I guess that this is probably what you want. It is possible to write a macro to do this once when the workbook is opened. I will leave that up to you

    I don't think you understand how frustrating it is to try and help somebody when the requirements are so poorly defined.
    All this has taken me 10 times as long as it took to write the code.

    By the way I now have better guess as to what your "Undo" might require and my post #4 doesn't do it.

  13. #13
    Hi,
    I'm sorry... I agree that I haven't defined clearly about my need. This is not my subject to do. But as a chemist, I need to arrange my data in order so I tried to make some attempts in doing it. But, first I will sort out how to explain clearly and then I will arrange my data!
    I'm sorry about that, I really understand how frustrating it will be you to write the code and execute it.
    Thanks a lot for your effort.

Posting Permissions

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