Noob Questions.

JuuchiYosamu

New Member
Joined
Mar 15, 2022
Messages
2
Office Version
  1. 365
Platform
  1. 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
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi & welcome to MrExcel.
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

‘first Command

Dim Z As Long

Dim xVal As String

On Error Resume Next

If Not Intersect(Target, Range("F:F")) Is Nothing Then

Application.EnableEvents = False

For Z = 1 To Target.count

If Target(Z).Value > 0 Then

Call MoveBasedOnValue

End If

Next
End If
Application.EnableEvents = True



‘second Command

Dim xRg As Range

On Error Resume Next

Set xRg = Intersect(Range("A2:E2000"), Target)

If Not xRg Is Nothing Then

Target.Worksheet.Unprotect Password:="DMNE"

xRg.Locked = True

Target.Worksheet.Protect Password:="DMNE"

End If


End Sub
 
Upvote 0
Solution
Thank you so much! My wife is overjoyed. She was working on it for a while.
Hi & welcome to MrExcel.
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

‘first Command

Dim Z As Long

Dim xVal As String

On Error Resume Next

If Not Intersect(Target, Range("F:F")) Is Nothing Then

Application.EnableEvents = False

For Z = 1 To Target.count

If Target(Z).Value > 0 Then

Call MoveBasedOnValue

End If

Next
End If
Application.EnableEvents = True



‘second Command

Dim xRg As Range

On Error Resume Next

Set xRg = Intersect(Range("A2:E2000"), Target)

If Not xRg Is Nothing Then

Target.Worksheet.Unprotect Password:="DMNE"

xRg.Locked = True

Target.Worksheet.Protect Password:="DMNE"

End If


End Sub
Thank you so much! My wife is overjoyed. She was working on it for a long time and she was getting nowhere.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,595
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top