Excel addicted
New Member
- Joined
- Sep 17, 2019
- Messages
- 14
Hello guys
I'm so glad to be part of this forum and to learn and share excel best practices.
I'm a novice in VBA and need some help on the following. I created a check-list with a multirow highlight feature through VBA that I got inspired from an amazing guy.
However I can't copy and paste anymore. Plus the default undo button in excel is deactivated.
Here is following code :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range(" D22:I46 ")) Is Nothing Then
Dim Cell As Range
Range("A4").NumberFormat = "@"
If Target.Count > 1 And Target.Count < 50 Then
StopCode
For Each Cell In Selection
Range("A4").Value = Range("A4").Value & "(" & Cell.Row - 21 & ")"
Next Cell
ResetCode
Else
Range("A4").Value = "(" & Target.Row - 21 & ")"
End If
Else
Range("A4").ClearContents
End If
End Sub
Of course I added another code which is linked to the one above to make the application run faster
Sub StopCode()
With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
End Sub
Sub ResetCode()
With Application
.EnableEvents = True
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub
Thanks in advance for your time and I appreciate your effort in case you find the solution and try to explain it in a easy way
I'm so glad to be part of this forum and to learn and share excel best practices.
I'm a novice in VBA and need some help on the following. I created a check-list with a multirow highlight feature through VBA that I got inspired from an amazing guy.
However I can't copy and paste anymore. Plus the default undo button in excel is deactivated.
Here is following code :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range(" D22:I46 ")) Is Nothing Then
Dim Cell As Range
Range("A4").NumberFormat = "@"
If Target.Count > 1 And Target.Count < 50 Then
StopCode
For Each Cell In Selection
Range("A4").Value = Range("A4").Value & "(" & Cell.Row - 21 & ")"
Next Cell
ResetCode
Else
Range("A4").Value = "(" & Target.Row - 21 & ")"
End If
Else
Range("A4").ClearContents
End If
End Sub
Of course I added another code which is linked to the one above to make the application run faster
Sub StopCode()
With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
End Sub
Sub ResetCode()
With Application
.EnableEvents = True
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub
Thanks in advance for your time and I appreciate your effort in case you find the solution and try to explain it in a easy way