Posts by djagxk8

    I have two macros that work great independently, but for some reason I can't get them to work together.


    Macro 1:
    On worksheet 1, I have a data validation drop down list in cell F2. Any time the cell is selected (regardless of content), I want it to run the same macro (the macro is named "Size"). The code I am using for that, and where I suspect the problem is, is as follows:


    Code
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim KeyCells As Range
        Set KeyCells = Range("F2")
        Call Size
      End Sub


    Macro 2:
    This macro is the one that I have the code above calling. It works great when I call it manually, or attach it to a button, but for some reason I always get error messages when I run it from the macro above.




    The error says: "the cell or chart you're trying to change is on a protected sheet. To make a change, unprotect the sheet. You might be requested to enter a password."


    However, when I unprotect the sheet, and delete all the .protect / .unprotect tags from the code - the macro runs, but right at the end it freezes excel. I have no idea what the solution is - any help would be greatly appreciated.


    Thanks,
    D

    Re: Hide/Unhide rows in range if cell value = criteria


    The whole worksheet is unlocked at the moment, but I intend to lock it once I'm done.


    The values in the range B7:B75 are populated by a reference to another sheet. For example, B7 of my range says =Reference!A3. On the Reference sheet, cell A3 is determined by an index match function that is pulling from that reference sheet.

    Re: Hide/Unhide rows in range if cell value = criteria


    Please excuse my ignorance- yes I put the cursor in the code and hit F5.


    If by installing it in the worksheet module you mean right clicking the worksheet and selecting view code, and pasting the code under the code I already had there, then that's what I did.


    Perhaps they don't like running together? Not familiar with rules surrounding event codes, or if there's an order they need to be placed in.


    When I took the previous (hide columns) code out, and put in your code for the rows by itself, I got a run-time error '2147417848 (80010108)': Method 'Hidden' of object 'Range' failed.

    Happy (almost) Friday!


    The way this sheet is set up, each cell in Range B7:B75 contains a formula that updates to display a "0, 1, or 2" depending on information entered elsewhere on the sheet. I'm trying to write the macro so that whenever a cell in range B7:B75 =0, that particular row will hide. I also need it to unhide when it no longer = 0. I need this to update in real time whenever those values change.


    I already have a macro running on this sheet to hide columns in a similar manner (which works perfectly), but I can't figure out the hide/unhide rows part. Not sure if I should try to add it to my existing macro, or if I should create a second one to handle the rows... Here's the macro that works for the columns:


    Code
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Range("B1").Value = 4 Then
            Columns("H:N").EntireColumn.Hidden = True
        Else
            Columns("H:N").EntireColumn.Hidden = False
        End If
    End Sub


    Any help on this would be greatly appreciated!


    Thanks,
    DT

    Re: Hide shape if cell value equals specific amount


    You know, I have a another workbook that does this function but I didn't make it, so I'm not sure whether or not the code can be adapted to this workbook.



    I changed parts to reference my sheet, but I'm not sure what the "Call unhidemail" part means, or what PreVal means. I'm thinking I should change the line

    Code
    If Sheets("Sales LY (Monthly)").Range("AU2").Value <> PrevVal Then


    to say

    Code
    If Sheets("Sales LY (Monthly)").Range("AU2").Value = 1 Then


    but I'm still not getting anywhere.


    Thanks,
    DT

    Re: Hide shape if cell value equals specific amount


    Hi Max,


    In the tab with the button (which is also the tab the value in cell AU2), I put the following code:



    And in the reference tab, I put the code:



    But, it's not doing anything. Did I do all the steps correctly?


    Thanks,
    DT

    Re: Hide shape if cell value equals specific amount


    Hi Max,


    The sheet with the button is called Sales LY (Monthly). Right now that is the same sheet with AU2 on it. However, if it can come straight off my reference sheet and not have to refer back, that would be nice too.


    The name of my reference sheet is Reference, and the cell that AU was referencing is W14.


    Thank you,
    DT

    Re: Hide shape if cell value equals specific amount


    Hi Max,


    Thank you for the help! The change of value in AU2 is indeed running from a formula. It is coming from my reference tab in cell W14 (Reference!W14). This is where the calculation is taking place to determine whether or not the button should be hidden.


    Thank you!
    DT

    Good afternoon,


    I have a 3 shapes on my worksheet functioning as buttons, and I need one of those three to stay invisible unless certain criteria are met (specifically, cell AU2 equaling 1). Then, once the it becomes visible, I need it to disappear again after it is clicked (since clicking it will run another macro to zero out cell AU2). I hope this is enough information to help. Thank you in advance for your time!


    DT

    Re: Rename select tabs from cell references


    Solved! I didn't know you could refer to the array by codename rather than worksheet name.


    Re: Rename select tabs from cell references


    Okay, I don't know the solution, but I think I figured out the problem I'm having.


    The error is happening because my sheets aren't originally named "Sheet6", and so on. Is there a way to change the sheet names regardless of what they're original names are?


    Thanks again!
    DT

    Re: Rename select tabs from cell references


    Thanks Robert,


    For some reason it's just giving me the error message. Could it be because the cell I have it referencing for the name is populated by a formula?


    Here's what I have so far:




    Thanks,
    DT

    Good afternoon,


    I am totally stuck on this one. I have a document with 9 tabs in it, and I only want to rename tabs 4, 5, 6, and 7 from cell E3 in each of those tabs. Everything I try either renames all the tabs, or only tab 1. I greatly appreciate any help here!


    Thanks,
    DT