JuuchiYosamu
New Member
- Joined
- Mar 15, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hello, I was trying to help my wife out with this code for her job. I've used Excel like 2 times ever so that doesn't help. My understanding is she has 2 codes that work individually but not when put together. From browsing other topics I see you can only have one function in a doodad. I don't want to butcher anything, I'm sure you can extrapolate what I'm trying to say. I would appreciate any help on this, normally I can piece together code but since I know nothing about excel or how it's macros function I'm extremely lost. Thank you for your time.
This is one:
Private Sub Worksheet_Change(ByVal Target As Range)
‘first command
Dim Z As Long
Dim xVal As String
On Error Resume Next
If Intersect(Target, Range("F:F")) Is Nothing Then Exit Sub
Application.EnableEvents = False
For Z = 1 To Target.Count
If Target(Z).Value > 0 Then
Call MoveBasedOnValue
End If
Next
Application.EnableEvents = True
‘second command
Dim xRg As Range
On Error Resume Next
Set xRg = Intersect(Range("A2:E2000"), Target)
If xRg Is Nothing Then Exit Sub
Target.Worksheet.Unprotect Password:="DMNE"
xRg.Locked = True
Target.Worksheet.Protect Password:="DMNE"
End Sub
and this is the other:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Z As Long
Dim xVal As String
On Error Resume Next
If Intersect(Target, Range("F:F")) Is Nothing Then Exit Sub
Application.EnableEvents = False
For Z = 1 To Target.Count
If Target(Z).Value > 0 Then
Call MoveBasedOnValue
End If
Next
Application.EnableEvents = True
*This command removes a row based on input variable in a particular column (F) and pastes on a separate sheet. It relates back to the “MoveBasedOnVaue” command.
Dim xRg As Range
On Error Resume Next
Set xRg = Intersect(Range("A2:E2000"), Target)
If xRg Is Nothing Then Exit Sub
Target.Worksheet.Unprotect Password:="DMNE"
xRg.Locked = True
Target.Worksheet.Protect Password:="DMNE"
*This command auto locks cell after data entry
This is one:
Private Sub Worksheet_Change(ByVal Target As Range)
‘first command
Dim Z As Long
Dim xVal As String
On Error Resume Next
If Intersect(Target, Range("F:F")) Is Nothing Then Exit Sub
Application.EnableEvents = False
For Z = 1 To Target.Count
If Target(Z).Value > 0 Then
Call MoveBasedOnValue
End If
Next
Application.EnableEvents = True
‘second command
Dim xRg As Range
On Error Resume Next
Set xRg = Intersect(Range("A2:E2000"), Target)
If xRg Is Nothing Then Exit Sub
Target.Worksheet.Unprotect Password:="DMNE"
xRg.Locked = True
Target.Worksheet.Protect Password:="DMNE"
End Sub
and this is the other:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Z As Long
Dim xVal As String
On Error Resume Next
If Intersect(Target, Range("F:F")) Is Nothing Then Exit Sub
Application.EnableEvents = False
For Z = 1 To Target.Count
If Target(Z).Value > 0 Then
Call MoveBasedOnValue
End If
Next
Application.EnableEvents = True
*This command removes a row based on input variable in a particular column (F) and pastes on a separate sheet. It relates back to the “MoveBasedOnVaue” command.
Dim xRg As Range
On Error Resume Next
Set xRg = Intersect(Range("A2:E2000"), Target)
If xRg Is Nothing Then Exit Sub
Target.Worksheet.Unprotect Password:="DMNE"
xRg.Locked = True
Target.Worksheet.Protect Password:="DMNE"
*This command auto locks cell after data entry