Hoping someone can help me. Any and all help is appreciated. I have a worksheet that has multiple macros and conditional formatting in addition to utilizing worksheet_change and worksheet_selectionchange. I use this form for work and it is designed to be used as a worksheet that I can fill out repeatedly. I have one worksheet labeled "blank form" and then I just copy this each time I need to fill out another one while of course giving it a new name. Each one of these worksheets stay within the workbook. This is going to be hard to explain because I am not exactly Excel-savvy, but I have macros set up as buttons on the blank form (Admission, 5-day, IPA, etc.), to slightly modify this form as there are different iterations of this form. The only modifications are that some questions don't need to be answered so the macros are designed to fill with black to essentially get rid of things that don't need to be answered.
The first screen shot is my "blank form"
The second screen shot is my "modified" form using a macro.
Most of the conditional formatting is to either change the text from invisible (format---> ;;; ) to not invisible (format--->text) but there are a couple in there that will change the fill. I have helper columns that are set up to equal either true or false and these are what are being used with the conditional formatting.
I am using worksheet_selectionchange for select cells to equal something based on another cell. I have included a portion of this code. While it is not the entire code, it is just the same code repeated for different cells.
I am using worksheet_change to utilize Ucase and ProperCase. Everything was working great until I added in this code. Once I did, excel started crashing and I get a message stating that some conditional formatting was removed. More than that actually happens though. My macros disappear. I can still see my personal macrobook but my macros are gone and if I hadn't saved the code in a word file, I would have been back to step one. All the previous forms that I have already completed get messed up too. From what I can tell, the conditional formatting that has been deemed a problem and removed, is applied to all the sheets in this workbook, which include forms I have already filled out. It's a hot mess and it messes everything up! I have included my code below.
Is this interfering with the conditional formatting? Or is it the other way around? Can you not have conditional formatting apply to the same cells that are in a worksheet_change? Or is there something wrong with my code. Everything I know about macros/VBA is self-taught which is probably pretty apparent so feel free to tell me if I did anything wrong or if there is a way to simplify this. Everything was working without issue until I added in the above code to convert select ranges to Ucase of ProperCase.
Apologies if I didn't post something correctly or used an incorrect term. This is still pretty new to me so I am not aware of common courtesies when posting to this kind of forum.
The first screen shot is my "blank form"
The second screen shot is my "modified" form using a macro.
Most of the conditional formatting is to either change the text from invisible (format---> ;;; ) to not invisible (format--->text) but there are a couple in there that will change the fill. I have helper columns that are set up to equal either true or false and these are what are being used with the conditional formatting.
I am using worksheet_selectionchange for select cells to equal something based on another cell. I have included a portion of this code. While it is not the entire code, it is just the same code repeated for different cells.
VBA Code:
For Each RNG In Range("AG99")
If Range("AO99") = "N" Then
RNG.Value = "N"
End If
Next RNG
For Each RNG In Range("AG99")
If Range("AO99") = "" Then
RNG.Value = ""
End If
Next RNG
I am using worksheet_change to utilize Ucase and ProperCase. Everything was working great until I added in this code. Once I did, excel started crashing and I get a message stating that some conditional formatting was removed. More than that actually happens though. My macros disappear. I can still see my personal macrobook but my macros are gone and if I hadn't saved the code in a word file, I would have been back to step one. All the previous forms that I have already completed get messed up too. From what I can tell, the conditional formatting that has been deemed a problem and removed, is applied to all the sheets in this workbook, which include forms I have already filled out. It's a hot mess and it messes everything up! I have included my code below.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub
On Error Resume Next
If Not Intersect(Target, Union(Range( _
"AC78:AD80,AK77:AL80,AS77:AT80,L80,R80,C81:C82,C86:C94,K86:K94,AG81,AG83,Y82:Y84,AY82:AZ82,AY83:AZ83,G96:H96,G98:H98,AG88:AN88,AG90:AN92,AG95:AN95,AG97:AN98,Y86,AG86,AO86,AO87:AZ99,H17,P17:P19,R16:S16,T16:T19,AA17:AA18,AI16:AM16,G21:L21,G24:L24,S20:S22" _
), Range( _
"AA20:AA22,AH21:AH25,AP21:AP24,AP28:AP31,AU32:AZ32,AX38:AZ38,AY44:AZ44,AP45:AP47,AP49:AP54,AY48:AZ48,AP56:AQ59,AP60:AQ60,AY64:AZ64,AP65,AU65,C38:C65,V38:V65,K66:N66,C67:C70,Y71:AR74,AW71:AZ74,C72:C79,AD77,AU86,AJ67:AO68" _
))) Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
Target = UCase(Target)
Application.EnableEvents = True
End If
If Not Intersect(Target, Range("J13")) Is Nothing Then
Application.EnableEvents = False
Target = StrConv(Target, vbProperCase)
Application.ScreenUpdating = True
Application.EnableEvents = True
End If
On Error GoTo 0
End Sub
Is this interfering with the conditional formatting? Or is it the other way around? Can you not have conditional formatting apply to the same cells that are in a worksheet_change? Or is there something wrong with my code. Everything I know about macros/VBA is self-taught which is probably pretty apparent so feel free to tell me if I did anything wrong or if there is a way to simplify this. Everything was working without issue until I added in the above code to convert select ranges to Ucase of ProperCase.
Apologies if I didn't post something correctly or used an incorrect term. This is still pretty new to me so I am not aware of common courtesies when posting to this kind of forum.