+ Reply to Thread
Page 4 of 6 FirstFirst ... 23456 LastLast
Results 46 to 60 of 79

Thread: Do's and Don'ts So Others Won't

  1. #46
    Forum Guru Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,281

    Re: Do's and Don'ts So Others Won't

    Here is more for the do or don't thread.
    While in VB editor, there is the option to insert a new module or, the actual worksheet can have code written into it. I guess my question is, when is it appropriate to insert code into the worksheet? I mostly use modules but I have inserted code into worksheets when I am designing a worksheet. Is there a do or don't for code in worksheets compared to modules? Some insight is appreciated as always.
    Please leave a message after the beep!

  2. #47
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Nowhere
    MS-Off Ver
    None
    Posts
    8,275

    Re: Do's and Don'ts So Others Won't

    As a general rule, event code (for the sheet and its objects) goes in a sheet (or workbook) module. Everything else goes in a normal module. There are different schools of thought, but they're wrong.

  3. #48
    Forum Guru Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,281

    Re: Do's and Don'ts So Others Won't

    Quote Originally Posted by romperstomper View Post
    There are different schools of thought, but they're wrong.
    Thanks romperstomper, lol, I'll take your word as gospel on the matter then.
    Please leave a message after the beep!

  4. #49
    Forum Guru Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,281

    Re: Do's and Don'ts So Others Won't

    @romper, nice carving by the way for your avatar. Did you carve it? It is a pumpkin right?
    Please leave a message after the beep!

  5. #50
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Nowhere
    MS-Off Ver
    None
    Posts
    8,275

    Re: Do's and Don'ts So Others Won't

    Yes, and yes. Thank you - my daughter wasn't impressed by any of them!

  6. #51
    Forum Guru
    Join Date
    10-28-2008
    Location
    Not here anymore
    MS-Off Ver
    irrelevant
    Posts
    10,152

    Re: Do's and Don'ts So Others Won't

    my daughter wasn't impressed
    Appreciation of art will not develop before the age of 3.

  7. #52
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,006

    Re: Do's and Don'ts So Others Won't

    Quote Originally Posted by davegugg View Post
    Alright, pop-quiz hot shots. Do you re-use variables? If you have multiple (non-nested) loops, do you re-use i for integer?
    What if you use a string to find a workbook name using the application.getopenfilename dialog box. Would you redefine the string after opening the workbook to get rid of the path in the name?
    I still use J as a loop variable where the loop is just a counter, if I actually do anything with the loop variable a more meaningful name is appropriate!!
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  8. #53
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,006

    Re: Do's and Don'ts So Others Won't

    If you just wanted the total of hours, add column D as a helper to your first sheet :-

    =Month(a1)

    then you can total for each month with :-

    =SUMIF(Sheet1!$D$2:$D$13,9,Sheet1!$C$2:$C$13)-SUMIF(Sheet1!$D$2:$D$13,9,Sheet1!$B$2:$B$13)

    Pivot table is the best way to go!!!!!!
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  9. #54
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,812

    Re: Do's and Don'ts So Others Won't

    and that answers what question squig?
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  10. #55
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,006

    Re: Do's and Don'ts So Others Won't

    oops, blush! erm it answered on question somewhere!
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  11. #56
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,006

    Re: Do's and Don'ts So Others Won't

    Ok if the post below answers your question then YEY, otherwise oops!
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  12. #57
    Forum Guru Domski's Avatar
    Join Date
    12-14-2009
    MS-Off Ver
    What does it matter?
    Posts
    3,933

    Re: Do's and Don'ts So Others Won't

    I think you'll find the answer is 42

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  13. #58
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,006

    Re: Do's and Don'ts So Others Won't

    and the question then must be "What is your age?!"
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  14. #59
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    MS 2007
    Posts
    5,372

    Re: Do's and Don'ts So Others Won't

    I was very disappointed in the final book of that series. Sighhhh
    ChemistB
    My 2¢

    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

  15. #60
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: Do's and Don'ts So Others Won't

    A lot was made previously about using GoTo, but how do you handle errors without using Goto? Or is error handling the one exception?
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0