A lost newbie

  • First off all, hello all!

    I'm new to Excel VBA and also new to this forum and I've run into a problem which I haven't been able to solve. It has to do with userforms.

    This whole thing is an assignment for school. I'm studying and this is one of the assingments.

    I have two files, one which is working and one that isn't. The working one is not like my teachers want to see it, because all the data is in the simform. They want me to spread the calculations etc. out over the modules. But I can't seem to make this work. All cells have value 0 in the not working file. I'm not sure if it has to do with the data from the simform not being passed on (all the variables are defined as public in a module) or if I'm doing something else wrong. It probably is something easy to fix.


    I attached the files. I hope someone can help me out.

    Thanks in advance!

    Files

    • Working.xlsm

      (103.09 kB, downloaded 18 times, last: )
    • Not working.xlsm

      (102.92 kB, downloaded 18 times, last: )
  • Could you give an example? If I look over it it seems everything does have a value.

    Thanks!

  • I managed to fix most things, just one thing doesn't seem to work. As you can see, there are still 3 colums which are displaying 0. This is linked to a sub which retrieves data from another sub in another module that loops, so it has multiple outcomes, which I all need. The variables are defined public in the module. Do I need to store these values in an array? And how can I do this the easiest?

  • I just looked at your userform, you are using variables in that but when it tries to calculate an error occurs because the variables do not have any values.

  • Okay, got most of this solved now. Thanks Roy!

    The last thing is that 3 colums corresponding to 1 sub are all showing the same number. I know why it does this, because the variable that contains these values is in another sub and loses its value at every loop so only the value from the last loop is remembered. How can I store these values from every loop the easiest way? I tried some things with arrays but didn't have good luck so far.

  • The variables are defined public, but they take the value from the last loop. When the sub that needs these values is called, The only value it knows is the value that is remembered from the last loop