+ Reply to Thread
Results 1 to 16 of 16

How to set Outside Procedure?

  1. #1
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    How to set Outside Procedure?

    Hi everyone,

    I have the following codes used with a user form, but they are all not working due to an outside procedure problem, any suggestions?

    Please Login or Register  to view this content.
    Thanks,

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to set Outside Procedure?

    Do you mean you want UN & PW as Constants ?

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: How to set Outside Procedure?

    Exactly,, Thanks alot,

  4. #4
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: How to set Outside Procedure?

    Hi all,

    What if we want to use the same property with Ranges like:

    Please Login or Register  to view this content.
    It is giving an error!

    Is there another property to set an outside procedure for ranges that can be used for all modules codes, all forms codes and all modules and forms codes in a workbook?

    Thanks,

  5. #5
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: How to set Outside Procedure?

    Please Login or Register  to view this content.
    I don't think you will be able to do the above.
    Const means CONSTANT, as in it doesn't change, but your range is dynamically finding the end of the data, so it CAN'T be const.
    Also the action of determining that range has to take place at some point, so it can't be outside of a procedure.
    What you could do is something like this:

    Please Login or Register  to view this content.
    Of course you "MyRange" will only be selecting all of your data as long as it doesn't change dimensions. If part of the rest of your code adds an extra line to the worksheet, then "MyRange" will still refer to the old size.

  6. #6
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: How to set Outside Procedure?

    Now I am using as same code as you provided merged with (with) property, but I have many controls in the userform .. do I have to repeate the same Range in all of them???

  7. #7
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: How to set Outside Procedure?

    No you could have the range set almost anywhere you like, perhaps in the workbook open routine, IF it is not going to change.

  8. #8
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: How to set Outside Procedure?

    Can You please provide me with an example of that Phil??

  9. #9
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: How to set Outside Procedure?

    I have the following placed in the 'ThisWorkbook' area of code in the VBA Editor. Then you can use 'MyRange' anywhere that you need to reference that range.

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: How to set Outside Procedure?

    That's sooooooo great,

    Thank you very much ,, that's what I am looking for since a long time.

  11. #11
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: How to set Outside Procedure?

    Hi,

    After testing the code providied by Phil_V, it seems that the workbook doesn't recognize the range at workbook startup (Auto_Open), so when the range is needed to run a macro completely an error msg appears telling that an object is required ( I think the required object is the range we referred to in Auto_Open).

    Can you please find me a solution for that problem?

    Thanks,

  12. #12
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: How to set Outside Procedure?

    Hi everyone,

    I really need to know how to set a public range for the whole workbook, I don't think that is not possible in VBA,

    Can you please help me???

  13. #13
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Thumbs up Re: How to set Outside Procedure?

    Sorry, I have been away for a while, it's very strange that it doesn't work properly, but a slight change sorts that out

    In the 'ThisWorkbook' code area:

    Please Login or Register  to view this content.
    Then in Module1 (or where you are writting your code):

    Please Login or Register  to view this content.
    Obviously when you run the "Put_In_Ones" macro it will fill your range with 1's. Not overly useful, but shows that it works.
    Of course don't forget as well that you MUST already have some data in Column C of Sheet2 after row 4, otherwise your range will be invalid.

  14. #14
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: How to set Outside Procedure?

    Hi,

    The problem is still existing, Can you please post a workbook contains an example for that.

    Thanks,

  15. #15
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How to set Outside Procedure?

    Hello LoveCandle,

    The following macros will return the range on Sheet2 from $C$4 to $C$100.

    Use this code if the range is variable, it will return the last used cell between $C$4 and $C$100. Copy this code to a standard VBA module.
    Please Login or Register  to view this content.
    Adding the Macro
    1. Copy the macro above pressing the keys CTRL+C
    2. Open your workbook
    3. Press the keys ALT+F11 to open the Visual Basic Editor
    4. Press the keys ALT+I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Paste the code by pressing the keys CTRL+V
    7. Make any custom changes to the macro if needed at this time.
    8. Save the Macro by pressing the keys CTRL+S
    9. Press the keys ALT+Q to exit the Editor, and return to Excel.

    Use this code if the range won't change after the workbook is opened. There are 2 parts to this. Use the procedure above to save this code.
    Standard Module Code
    Please Login or Register  to view this content.
    Use the procedure below to save this macro.
    Workbook_Open() Code
    Please Login or Register  to view this content.
    How to Save a Workbook Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on any Worksheet's Name Tab
    3. Left Click on View Code in the pop up menu.
    4. Press ALT+F11 keys to open the Visual Basic Editor.
    5. Press CTRL+R keys to shift the focus to the Project Explorer Window
    6. Press the Down Arrow Key until ThisWorkbook is highlighted in blue.
    7. Press the Enter key to move the cursor to the Code Window
    8. Paste the macro code using CTRL+V
    9. Save the macro in your Workbook using CTRL+S
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  16. #16
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: How to set Outside Procedure?

    Leith Ross, Thank you so much for your detailed clear reply,

+ 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.6.0 RC 1