VBA working fine apart but not together

grippa87

New Member
Joined
Sep 26, 2017
Messages
3
Hi legends,

I have these 2 macros I modified from around the place and when I was testing separately on 2 sheets both worked great.

I've tried to put them together but now after the barcode scanner scans 3 spaces it drops down a row and back 3 columns until scanned then it jumps up and right 1 cell.

so its supposed to start at column B and remove a letter from the end of the barcode when scanned either A,B,C or D.

Then when scanning from Column B 3 times drop down to a new row and back to the original column B and repeat

please any help would be amazing here it is



Option Explicit


Private Sub Worksheet_Change(ByVal Target As Range)
Call Worksheet_Change1(Target)
Call Worksheet_Change2(Target)
End Sub








Private Sub Worksheet_Change1(ByVal Target As Range)
If Intersect(Target, Range("B12:B27")) Is Nothing Then Exit Sub
If Target.Count > 1 Then Exit Sub
If Target = "" Then Exit Sub
With Application
.EnableEvents = False
.ScreenUpdating = False
If Right(Target, 1) = "A" Then Target = Left(Target, Len(Target) - 1)
If Right(Target, 1) = "B" Then Target = Left(Target, Len(Target) - 1)
If Right(Target, 1) = "C" Then Target = Left(Target, Len(Target) - 1)
If Right(Target, 1) = "D" Then Target = Left(Target, Len(Target) - 1)
.EnableEvents = True
.ScreenUpdating = True

End With
End Sub


Private Sub Worksheet_Change2(ByVal Target As Range)


On Error GoTo Exit_Clean
Application.EnableEvents = False


If Target.Row > 11 And Target.Column = 4 Then
ActiveCell.Offset(1, -3).Select

End If


Application.EnableEvents = True
Exit_Clean:
Application.EnableEvents = True
On Error GoTo 0

End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Use code tags (# in editor) to make it easier to read.

Try changing
Code:
[COLOR=#333333]ActiveCell.Offset(1, -3).Select[/COLOR]

to
Code:
[COLOR=#333333]Target.Offset(1, -3).Select[/COLOR]
Skip down a row and back 3 columns, as Offset(rows,columns)
 
Upvote 0
Thanks for the help but it didn't help. And sorry about the # where should I used them?

The loop doesn't happen any where else on the sheet just in the main table where I need it lol
 
Upvote 0


In the message editor will add tags to keep the code nice and together.

I'll look into your issue again, but it might be a couple days!
 
Upvote 0
Hi

Turns out I just had a moment lol.

The following cell was merged so it thru it all out.

All fixed appreciate the help
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,575
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