+ Reply to Thread
Results 1 to 6 of 6

How to change this code into private sub

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    How to change this code into private sub

    Hello,

    I have a code below and wonder if you can modify this into private sub. Thanks

    Sub macro2()
    
    
    If ActiveSheet.Range("Y4") > 10 / 100 Then
        ActiveSheet.Shapes.Range(Array("Freeform 42")).Fill.ForeColor.RGB = vbGreen
        ElseIf ActiveSheet.Range("Y4") < 9.99 / 100 And ActiveSheet.Range("Y4") > 5.99 / 100 Then
        ActiveSheet.Shapes.Range(Array("Freeform 42")).Fill.ForeColor.RGB = vbYellow
        ElseIf ActiveSheet.Range("Y4") < 5.99 / 100 Then
        ActiveSheet.Shapes.Range(Array("Freeform 42")).Fill.ForeColor.RGB = vbRed
    
    End If
    End Sub

  2. #2
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: How to change this code into private sub

    In general you can do that by doing this....

    Private Sub Macro2()
    but that depends on what you mean by private....
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  3. #3
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: How to change this code into private sub

    I tried that and it does not work. I just want this code automatically execute without clicking button

  4. #4
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: How to change this code into private sub

    so when you open the workbook (excel file) you want it to automatically launch this marco?....if true, change the name of the marco to Sub Auto_Open()

  5. #5
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: How to change this code into private sub

    Can you do it when the worksheet_change instead?

  6. #6
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: How to change this code into private sub

    most definitely....you just have to choose what kind of "change" you are looking for....IE: if a change to this column or this row or this cell then run this macro....

+ 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. Private Sub Worksheet Change Help please!
    By darrenkaye in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-29-2013, 12:55 PM
  2. [SOLVED] Private sub worksheet change, run when two seperate cells change
    By jtd84 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-11-2012, 06:47 PM
  3. Private Sub Worksheet Change Help
    By jacksaudio in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-07-2011, 06:18 AM
  4. Cell Change Private Sub
    By bakes1 in forum Excel General
    Replies: 5
    Last Post: 01-31-2007, 12:10 PM
  5. [SOLVED] Private Function Code Change
    By Phil H in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-14-2006, 09:10 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