+ Reply to Thread
Results 1 to 11 of 11

ThisWorkbook Private Sub, two or more subrutines?

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

    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 2016
    Posts
    3,816

    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 ( It doesn't hurt )

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

    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
    205

    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 2016
    Posts
    3,816

    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 2016
    Posts
    3,816

    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
    205

    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
    205

    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 2016
    Posts
    3,816

    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
    205

    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 2016
    Posts
    3,816

    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?

+ 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