Consulting

Results 1 to 11 of 11

Thread: Get values in sheet2 from sheet1 data

  1. #1
    VBAX Regular
    Joined
    Jan 2006
    Posts
    7
    Location

    Red face Get values in sheet2 from sheet1 data

    I am having problems... stuck... I don't know what to do next...I don't know how to command... I just hoped it would work but.. no...please help me...
    I am trying to calculate two ways of traveling distance flying and driving. I am subtracting distancest that is not acquire for an actual distance. If I traveled twice, by air and by car. I want to have a table (like on sheet2). Can anyone please help me or fix my macro that doesn't make sense but only to me?
    Last edited by fanoftu; 02-01-2006 at 05:00 PM. Reason: forgot to attach a file

  2. #2
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Hello fanoftu Welcome,

    I see that you edited your post to try to include a file...but I don't see a file could you try again, and I'll be more than happy to help out

    Thanks,




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  3. #3
    VBAX Regular
    Joined
    Jan 2006
    Posts
    7
    Location

    hum....

    This is what I want my macro to work so i can use this for my further travel distances...I am hoping someone can rescue me... I have ..tried... different ways.. and I don't know if I am even doing the right thing to excute this.. marco...


    Isabel
    Last edited by fanoftu; 02-02-2006 at 01:42 PM. Reason: This is what I really want to make it work

  4. #4
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location

  5. #5
    VBAX Regular
    Joined
    Jan 2006
    Posts
    7
    Location

    Unhappy

    oh.. i thought this was a different one.... well as u can see.. i am clinging for a help.. am i still not making sense at all?... I should just quit.. egh?

  6. #6
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location


    Sorry fanoftu, but I was almost finished with your file and Excel crashed on me

    Man that's aggravating (as I'm sure you can tell)....and I was so close

    If no one solves this by tomorrow...I'll give another crack at it


    Even though I lost the info...here's what you can look into:

    1. Userform_Initialize - use this to set the listbox items. I noticed if you ran the macro while in Sheet2, the listbox wouldn't fill correctly.
    2. Unload Me / Userform1.Hide - this you should use to hide the userform(1 or 2) when you hit the OK button.
    3. Public Variables - place one of these in the Module1 code you have, name it monthSelected and declare it as a string. Once the OK button is selected from UserForm1 --> monthSelected = ListBox1.Text ...now you can use this for the other userform to find the month in Sheet1 and use Offset to get the corresponding value depending on which option you choose.
    4. Double check Syntax - I noticed your syntax is incorrect here (along with the option2's syntax)...
    Worksheets("sheet2").Value = x
           z = x - Range("b")
    You can't set a worksheet to a value...at least not that I know of . You need to specify a Range. And you are not selecting a correct Range with "Range("b")", there needs to be a number after "b". EDIT: You should also specify a Sheet.



    ...Just to get you started
    Last edited by Aussiebear; 04-19-2023 at 03:52 PM. Reason: Adjusted the code tags




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  7. #7
    VBAX Regular
    Joined
    Jan 2006
    Posts
    7
    Location

    Smile

    I will try to do what you are saying... If i understood VB better.. I would know what you are saying..but I am still learning little by little and this is so frustrating... and I am so sorry that it crashed...why that doesn't happen to me so i have an excuse??? <<< Me So.. If i can't set the worksheet put a value... how am i getting a value? on each row or column.??? omg.. I feel flying stupid about now... ( ) sighs.. Thank you so much for your help now, I guess it might seem to work little further than what i have now... )

    Isabel

  8. #8
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Nah don't feel stupid...it's all about learning

    You need to state a specific range to collect a cell's value:
    Msgbox Sheets("Sheet1").Range("A1")
    This tells you cell A1's value on sheet1.


    Check this place out: http://www.geocities.com/WallStreet/9245/

    Maybe it will help you out
    Last edited by Aussiebear; 04-19-2023 at 03:53 PM. Reason: Adjusted the code tags




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  9. #9
    VBAX Regular
    Joined
    Jan 2006
    Posts
    7
    Location
    where do we put? Userform_Initialize , inside of ok box in userform1 or inside of listbox1 or.. somwhere else? or make new one? or ?... should i just stay quiet? for now?... sighs...

  10. #10
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Userform_Initialize goes within the Form's code, but by itself. Right-click your Userform1 and select "View Code" and...
    Private Sub Userform_Initialize()
    'Initial Items such as the list box
    End Sub
    That's all for tonight...I'm going to sleep now aaahhh....bed

    I'll look at this tomorrow night And if you get an answer before then on the other site, please let us know
    Last edited by Aussiebear; 04-19-2023 at 03:54 PM. Reason: Adjusted the code tags




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  11. #11
    VBAX Regular
    Joined
    Jan 2006
    Posts
    7
    Location
    I still getting error messages... I think I am out of my knowledges to fix the problem... sighs...any helpers?

Posting Permissions

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