Posts by amuza

    Re: Customize Chart From Combo Box Selections


    Thanks for the response. I've already got that equation into the define name for XValue1. What I would like to do though is be able to alter this equation through a user's selection in a combo-box. So the XValue1 is "=OFFSET(INDIRECT(Sheet1!$H$9),1,Sheet1!$I$7-1,101,1)" when Sheet1 is selected, but the equation for XValue1 changes to "=OFFSET(INDIRECT(Sheet2!$H$9),1,Sheet1!$I$7-1,101,1)" when Sheet2 is selected so the different set of data is represented in the graph.

    Re: Customize Chart From Combo Box Selections


    Ok, so going back to what I had posted on this thread before. I reattached the file that was a few posts before, but put in the defined names. I wanted to put in an extra sheet but it would make the file too big. But what I want to be able to do is to not only let the user select the X and Y axis, but also choose which set of data they want to look at without having to go to a seperate graph. This sepereate data would be on a seperate sheet such as Sheet2. As of now I'm defining names for the multiple sets of data within a workbook as I get more data(e.g. XValue1 & YValue1, XValue2 & YValue2, ....) and adding them to the source data and displaying them all at the same time but would prefer to show them all seperate. Any help would be appreciated.

    Re: Error When Picture Is Loaded


    Thanks for the interest, but I ended up not using that code and going with one as follows:



    If you can think of a way that I could have the pictures(all with name MyPic) be deleted when the fusenumber1 value changes, that would be beneficial.

    So I found this thread that gave a code(written by Damon Ostrandor) which would delete a picture and than add a new one in it's place. I would've just replied there, but the thread had expired. When I ran this code, it worked by deleting the image that was there and putting the correct new one in it's place, but everytime i chose a new file the picture comes up and excel says that it has encountered a problem and must close. Any thoughts on why this happens?




    Now try in a cell


    =ShowPicD("C:\Documents and Settings\tmuza\Desktop\New Database\Database Images\312\312_250\"&I12&".jpg")


    where I12 houses the picture/file name.

    I have a more general question. When doing something such as loading a picture, is it possible to be able to have code which the loading file name changes with a variable. For example, if I have pictures with names 1.jpg thru 120.jpg(all in the same directory) is it possible to write a code that loops and loads the proper image without having to write a section of code for each file name? This would be the directory(C:\Documents and Settings\tmuza\Desktop\New Database\Database Images\312\312_250) so could I code the filename calls something like this with having picname be the variable which goes from 1 to 180:


    Code
    .Pictures.Insert( _ 
    "C:\Documents and Settings\tmuza\Desktop\New Database\Database Images\312\312_250" & picname & ".jpg").Select

    Re: Delete Image Before Loading New Image`


    TodKerr/AndyPope, I put digging deep sub with the ZOrderPosition into the code but am unsure what I would need to put where the x is or whether it should work as written because as of now it doesn't delete when I run it.

    I've written a code in which based on selections made by a user, a specific picture is inserted onto the worksheet. I got it to load the correct file into the correct cell, but when choosing more combinations of selections the old image still remains behind the new image when it appears. I know that visually it looks like only one image is there but previously viewed images remain behind. Is there a code which would delete the current image in a cell so that I would be able to put that at the beginning of my main code and have it delete the image that was previously viewed? Any thoughts would be appreciated.

    Re: Error Within Nested For Loop


    Thank you for the replies. Although the suggestions cleared up a couple of things, the main task at hand was still not solved. Still looking at the code from a previous post, I've attached an excel sheet which may clarify what I'm looking for a little better. Within the sheet, you can select using combo-boxes what you want for a, b and c. And as you can see from the B3:E63, there are 60 possible combinations of the variables. I would like for my code to dtake in these three selections(a, b, and c) and come up with what corresponding number is being looked at.

    So I'm writing this code which determines the number based on values of a, b, and c. I figured a nested for loop was the best approach where there are 10 possible selections for a, 2 for b and 3 for c giving a total number of 60 combinations. When I try to run this though it gives me this:"Complie error: next without for" and highlights the first Next on line 14. From what I can tell, that Next does have a For connected to it but maybe I'm missing something. Any advice or corrections would be appreciated.


    Below is the code, but on here the for's and next's don't line up as they do in my actual code in VBA.


    I was wondering if it's at all possible for a user's selection to determine the name of the file to be opened. For example, below is just a section of my code and when satisfying the elseif statement the correct number appears. What I have happening is the three picture from file being inserted into the three ranges. The problem I have is that the code would be exceedingly long if I continued with this throughout the entire code. Is there a way I could insert the variable "number" as the file name that I'm inserting?


    Code
    ElseIf a = 2 b = 2 And c = 1 Then
            number = 28
            InsertPictureInRange "C:\Documents and Settings\tmuza\Desktop\New Database\Database Images\312\312_250\28.jpg", _
            Range("I7")
            InsertPictureInRange "C:\Documents and Settings\tmuza\Desktop\New Database\Database Images\312\312_250\29.jpg", _
            Range("I19")
            InsertPictureInRange "C:\Documents and Settings\tmuza\Desktop\New Database\Database Images\312\312_250\30.jpg", _
            Range("I31")

    Re: Display Images From Combo Box Selections


    Thanks Shg, that makes the code work. Now that I've got that, does anyone have an idea of what to do now to display certain images? The image number(what it's saved as) is what the previous code was written for. So now all I need is to have the values in three seperate cells load an image from a determined directory with the same number as it's name. I assume this can be done but the help in VBA as well as Excel aren't helping too much.

    Re: Display Images From Combo Box Selections


    As I'm working through this problem, I've come across a slight problem with my code which may be more simple to answer than my initial post. I'm able to compile the code, but when run it's as if it is not running through the If...elseif statements because no matter what values are in the AB36, AB37 and AB38 cells, it always shows fusenumber as 0. The values being put into cells at the end is to check whether the initial variable equations worked. Am I not allowed to put the three conditions within the If statement? If not, how should this be done?


    Re: Displaying Separate Error Bars For Each Column On Chart


    Nevermind. Through messing around with a few things I found that by creating a seperate list of standard deviations and inserting that range into the custum error amount, the standard deviation error bars were correct for each column.

    I've plotted a column chart which has 6 different columns. Each column has a specific name and value for it as well as standard deviation which needs to be represented on the chart. I'm able to plot the columns with the correct labels underneath, but when trying to add the standard deviation error bars, it inserted the same standard deviartion for every column as well as at the same value. Any help with this would be great.

    Here's my situation: I have 180 different images to display with 60 different situations. This means that for every combination of 4 variables, there are 3 images. What I have set up right now are combo-boxes where a user would be able to select the situation which best suits them within the four variables. What I would like to happen would be to have the 3 images pertaining to the chosen variables appear within the worksheet. These images could be put within a worksheet or accessed through a folder.


    I'm a newbie when it comes to VBA coding but have a little background in other types so I figured setting up some type of if...elseif where i would have 60 different conditions leading to the display of the images. Any help of how to either write this up or maybe simplify what I'm trying to do would be greatly appreciated.

    Re: Customize Chart From Combo Box Selections


    Thanks for the help. I would also like to be able to have the Title change with the combo box selection as well as the axis labels. Is there a way to also incorporate this into the chart?