Hi all, having trouble with a user interface I'm creating.
I have many cells in my UI that need to be changed by the user, but when they change a particular 'trigger' cell I want some formatting done off to the side. The problem is, as I have it currently coded, the formatting occurs whenever the user changes any cell as opposed to the target cell. Any suggestions on how to make the formatting occur only when the target cell value is changed? Running 2007.
Thanks!
ieJasonW
Here's the code:
'***Layer Property
'***Dynamic Formatting
If Cells(13, 4).Select = True Then
Application.EnableEvents = False 'Must turn this off to alter the worksheet
nl = Cells(13, 4).Value 'Number of Layers
'clears the cells gives them plain formatting
For i = 1 To 50 'upto 50 layers of data
For j = 1 To 11 'for each of 11 layer properties
Cells(14 + i, 5 + j).Borders.ColorIndex = 2
Cells(14 + i, 5 + j).Interior.ColorIndex = 2
Cells(14 + i, 5 + j).ClearContents
Next j 'Next row
Next i 'Next column
'Writes in the 'layer' label for the first column of the Layer Properties table
For i = 1 To nl 'upto nl number of layers
Cells(14 + i, 7).Value = i
Next i 'Next layer
'Formats the inner cells of the Layer Properties Table
For i = 1 To nl 'for nl nomuber of layers
For j = 1 To 10 'for 10 layer properties
Cells(14 + i, 7 + j).Interior.Color = RGB(255, 255, 204) 'Set interior color to light grey
Cells(14 + i, 7 + j).Select 'select new cell
With Selection.Borders 'give selection a border
.LineStyle = xlContinuous
.Weight = xlThin
.Color = RGB(192, 192, 192) 'set color to peach
End With
Next j 'Next row
Next i 'Next column
Cells(14, 4).Select
Application.EnableEvents = True
End If 'End of Dynamic Formatting
I have many cells in my UI that need to be changed by the user, but when they change a particular 'trigger' cell I want some formatting done off to the side. The problem is, as I have it currently coded, the formatting occurs whenever the user changes any cell as opposed to the target cell. Any suggestions on how to make the formatting occur only when the target cell value is changed? Running 2007.
Thanks!
ieJasonW
Here's the code:
'***Layer Property
'***Dynamic Formatting
If Cells(13, 4).Select = True Then
Application.EnableEvents = False 'Must turn this off to alter the worksheet
nl = Cells(13, 4).Value 'Number of Layers
'clears the cells gives them plain formatting
For i = 1 To 50 'upto 50 layers of data
For j = 1 To 11 'for each of 11 layer properties
Cells(14 + i, 5 + j).Borders.ColorIndex = 2
Cells(14 + i, 5 + j).Interior.ColorIndex = 2
Cells(14 + i, 5 + j).ClearContents
Next j 'Next row
Next i 'Next column
'Writes in the 'layer' label for the first column of the Layer Properties table
For i = 1 To nl 'upto nl number of layers
Cells(14 + i, 7).Value = i
Next i 'Next layer
'Formats the inner cells of the Layer Properties Table
For i = 1 To nl 'for nl nomuber of layers
For j = 1 To 10 'for 10 layer properties
Cells(14 + i, 7 + j).Interior.Color = RGB(255, 255, 204) 'Set interior color to light grey
Cells(14 + i, 7 + j).Select 'select new cell
With Selection.Borders 'give selection a border
.LineStyle = xlContinuous
.Weight = xlThin
.Color = RGB(192, 192, 192) 'set color to peach
End With
Next j 'Next row
Next i 'Next column
Cells(14, 4).Select
Application.EnableEvents = True
End If 'End of Dynamic Formatting