+ Reply to Thread
Results 1 to 17 of 17

ThisWorkbook Private Sub, two or more subrutines?

  1. #1
    Forum Contributor
    Join Date
    11-26-2014
    Location
    Bosnia&Herzegovina
    MS-Off Ver
    Office2013
    Posts
    281

    ThisWorkbook Private Sub, two or more subrutines?

    Hi,

    Coluld I have two or more private sub in ThisWorkbook MicrossoftExcelObjects module?

    Please Login or Register  to view this content.
    First code is disabled, 'cause it isn't working at all when theere is two codes. I don't know how to combine them into one code using IF statemenet.

    Thank in advance dear people!

    p.s COde is for highlighting selected row between eg. column 15 to 28.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: ThisWorkbook Private Sub, two or more subrutines?

    Only One with the same name per module sheet or vba as long as it's private
    You can add as many If and If Then Else or Intersect commands to accommodate for different conditions.
    So If condition this and this and this then do that elseif other conditions then that elseif more conditions elseif etc. and end with End If
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,855

    Re: ThisWorkbook Private Sub, two or more subrutines?

    You can't have more than one event of same type, or it will cause conflict.

    Just use IF statement to change action.

    I'm not exactly sure what you are trying to do here. But try...
    Please Login or Register  to view this content.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  4. #4
    Forum Contributor
    Join Date
    11-26-2014
    Location
    Bosnia&Herzegovina
    MS-Off Ver
    Office2013
    Posts
    281

    Re: ThisWorkbook Private Sub, two or more subrutines?

    Not functioning.
    I have sheets "ED-5" and "List1"
    I need inside them after cell click or keyboard arrow select cell, to highlight row between area set in code.

    Sorry if bad English, too much Hollywood movies..

    Please Login or Register  to view this content.
    Sheet "ED-5" = columns between 15-28 and rows 6-2000, any click/select outside this range End Sub
    Sheet "List1" = columns between 1-23 and rows 2-1000, any click/select outside this range End Sub
    If ActiveSheet.name<>"ED-5" or ActiveSheet.Name<>"List1" please dear EXCEL End SUb.
    Last edited by B.W.B.; 02-11-2019 at 03:19 PM.

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: ThisWorkbook Private Sub, two or more subrutines?

    You code like your english is not that good and I hope I understood it correctly
    Try this

    Please Login or Register  to view this content.

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: ThisWorkbook Private Sub, two or more subrutines?

    Have you tried it?

  7. #7
    Forum Contributor
    Join Date
    11-26-2014
    Location
    Bosnia&Herzegovina
    MS-Off Ver
    Office2013
    Posts
    281

    Re: ThisWorkbook Private Sub, two or more subrutines?

    In conditional format i have formula =CELL("row")=ROW() with some formatting to highlight range(row).
    So i need Application.ScreenUpdating=True to activate formatting, i guess.

    If condition is false then go to next if (elseif) AkoGRESKA is iferror then END SUB

    I'll try the code,

  8. #8
    Forum Contributor
    Join Date
    11-26-2014
    Location
    Bosnia&Herzegovina
    MS-Off Ver
    Office2013
    Posts
    281

    Re: ThisWorkbook Private Sub, two or more subrutines?

    THIS IS IT, THANKS !!!!! But...

    Please Login or Register  to view this content.
    When i doubleclick outside range, it highlight row inside range anyway. Why?
    Single click is fine, but doubleclick, it highlight row even i'm outside that range.
    Last edited by B.W.B.; 02-12-2019 at 06:52 AM.

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: ThisWorkbook Private Sub, two or more subrutines?

    Doubleclick ? No code for double click, that is just Excel or maybe you p;lace some double_click code in the worksheets?
    And you do not need Application,Screenupdating for conditional format.
    That ALWAYS works, I was wondering why you had that.
    You could however add Activesheet.Calculate

  10. #10
    Forum Contributor
    Join Date
    11-26-2014
    Location
    Bosnia&Herzegovina
    MS-Off Ver
    Office2013
    Posts
    281

    Re: ThisWorkbook Private Sub, two or more subrutines?

    No, it's just, when i edit some cell range outside the range(column15-28 rows 6-200), why is format activated?

  11. #11
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: ThisWorkbook Private Sub, two or more subrutines?

    I don't know, I don't have the file I can't see it. It has nothing to do with the code I posted.
    what have you changed or added?

  12. #12
    Forum Contributor
    Join Date
    11-26-2014
    Location
    Bosnia&Herzegovina
    MS-Off Ver
    Office2013
    Posts
    281

    Re: ThisWorkbook Private Sub, two or more subrutines?

    Quote Originally Posted by B.W.B. View Post
    THIS IS IT, THANKS !!!!! But...

    Please Login or Register  to view this content.
    When i doubleclick outside range, it highlight row inside range anyway. Why?
    Single click is fine, but doubleclick, it highlight row even i'm outside that range.

    Single click is fine, select with keyboard arrow is also OK, but doubleclick, it highlight row even i'm outside that range. Why?

  13. #13
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: ThisWorkbook Private Sub, two or more subrutines?

    Without the file or the code ...
    Cannot say, is the worksheet protected and are the cells outside the range locked?

  14. #14
    Forum Contributor
    Join Date
    11-26-2014
    Location
    Bosnia&Herzegovina
    MS-Off Ver
    Office2013
    Posts
    281

    Re: ThisWorkbook Private Sub, two or more subrutines?

    Quote Originally Posted by Keebellah View Post
    Without the file or the code ...
    Cannot say, is the worksheet protected and are the cells outside the range locked?
    here filee
    Attached Files Attached Files
    Last edited by B.W.B.; 02-25-2019 at 03:06 PM.

  15. #15
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: ThisWorkbook Private Sub, two or more subrutines?

    I cannot find the code that highlights the range, but it it triggered only when you double click.
    Since the VBA is locked I cannot check the references in the Tools menu.
    You implemented something that highlights that row but not with the vba code you provided.
    When you double click you trigger an event

  16. #16
    Forum Contributor
    Join Date
    11-26-2014
    Location
    Bosnia&Herzegovina
    MS-Off Ver
    Office2013
    Posts
    281

    Re: ThisWorkbook Private Sub, two or more subrutines?

    Here code, first one works, second don't. It's just I don0t know or it can't have name like "Workbook2" to work.

    Please Login or Register  to view this content.
    First one, works, but when I select(doubleclick or BACKSPACE) cell outside the range, it highlight the same row as i'm inside the range. I don't want that. Please, highlight row only when I'm in range.
    Last edited by B.W.B.; 03-05-2019 at 09:37 AM.

  17. #17
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: ThisWorkbook Private Sub, two or more subrutines?

    First, WorkBook2 is not an Excel expression in these cases.
    NO GO

    You must integrate is in teh WorkBook_SheetSelectionChange
    I explained the reason, I cannot help you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Combine Private Sub and Private Function VBA code
    By thanhthinh1234 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2018, 06:16 AM
  2. Call Private Function under Private Sub
    By thanhthinh1234 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-25-2018, 03:23 AM
  3. [SOLVED] Using Application.Run to call a private sub in a module from ThisWorkbook object
    By Stormin' in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-24-2017, 10:47 AM
  4. [SOLVED] Calling a private procedure from ThisWorkbook
    By JimDandy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2016, 02:42 AM
  5. [SOLVED] Problem with ThisWorkbook Module: Two Private Sub Workbook_Open()
    By DavidRoger in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-22-2015, 11:28 AM
  6. [SOLVED] How to stop Private sub Sheet change (located at Thisworkbook) working in worksheet 3
    By alexnkc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2013, 09:34 PM
  7. re : Possible to run private sub macros by writing another private
    By ddiicc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-26-2005, 12:05 AM

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