ccarrillo54
New Member
- Joined
- Nov 29, 2018
- Messages
- 2
Hello, I'm trying to get my code to apply to all the sheets, in the workbook I am using. I've tried multiple ways and multiple codes, but nothing I have used worked. So the macro I'm using allows me to check in and out samples, along with the date right beside it. any other code I use to make the code apply to other sheets ends up in error. Please help me, I will greatly appreciate any help or input you can provide. here I the code I am working with.
Option Explicit
Sub Check_In()
Dim Code As String: Code = InputBox("Please scan a barcode", "Scan procedure")
If Code = "" Then MsgBox ("No code scanned"): Exit Sub
Dim NbChIn As Integer: NbChIn = application.CountIf(Range("STORE_RECORDS[CHECKED OUT on its way to analytical lab]"), Code)
Dim NbChOut As Integer: NbChOut = application.CountIf(Range("STORE_RECORDS[SAMPLE RECEIVED from analytical lab]"), Code)
If NbChIn > NbChOut And NbChIn > 0 Then
MsgBox ("This sample is already Checked-out" & Chr(10) & "Please click sample received and retry"): Exit Sub
Else
Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) = Code
Cells(Rows.Count, 1).End(xlUp).Offset(0, 1) = Now
End If
End Sub
Sub Check_Out()
Dim Code As String: Code = InputBox("Please scan a barcode", "Scan procedure")
If Code = "" Then MsgBox ("No code scanned"): Exit Sub
Dim NbChIn As Integer: NbChIn = application.CountIf(Range("STORE_RECORDS[CHECKED OUT on its way to analytical lab]"), Code)
Dim NbChOut As Integer: NbChOut = application.CountIf(Range("STORE_RECORDS[SAMPLE RECEIVED from analytical lab]"), Code)
If NbChIn = NbChOut And NbChIn > 0 Then
MsgBox ("This sample has already been received" & Chr(10) & "Please check it out and retry"): Exit Sub
Else
If Range("STORE_RECORDS[CHECKED OUT on its way to analytical lab]").Find(Code, , , xlWhole, , xlPrevious) Is Nothing Then MsgBox ("No match, ask Carlos !"): Exit Sub
Range("STORE_RECORDS[CHECKED OUT on its way to analytical lab]").Find(Code, , , xlWhole, , xlPrevious).Offset(0, 2) = Code
Range("STORE_RECORDS[CHECKED OUT on its way to analytical lab]").Find(Code, , , xlWhole, , xlPrevious).Offset(0, 3) = Now
End If
End Sub
Here is a preview of what my template looks like, set up in table format.
<tbody>
</tbody>
Option Explicit
Sub Check_In()
Dim Code As String: Code = InputBox("Please scan a barcode", "Scan procedure")
If Code = "" Then MsgBox ("No code scanned"): Exit Sub
Dim NbChIn As Integer: NbChIn = application.CountIf(Range("STORE_RECORDS[CHECKED OUT on its way to analytical lab]"), Code)
Dim NbChOut As Integer: NbChOut = application.CountIf(Range("STORE_RECORDS[SAMPLE RECEIVED from analytical lab]"), Code)
If NbChIn > NbChOut And NbChIn > 0 Then
MsgBox ("This sample is already Checked-out" & Chr(10) & "Please click sample received and retry"): Exit Sub
Else
Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) = Code
Cells(Rows.Count, 1).End(xlUp).Offset(0, 1) = Now
End If
End Sub
Sub Check_Out()
Dim Code As String: Code = InputBox("Please scan a barcode", "Scan procedure")
If Code = "" Then MsgBox ("No code scanned"): Exit Sub
Dim NbChIn As Integer: NbChIn = application.CountIf(Range("STORE_RECORDS[CHECKED OUT on its way to analytical lab]"), Code)
Dim NbChOut As Integer: NbChOut = application.CountIf(Range("STORE_RECORDS[SAMPLE RECEIVED from analytical lab]"), Code)
If NbChIn = NbChOut And NbChIn > 0 Then
MsgBox ("This sample has already been received" & Chr(10) & "Please check it out and retry"): Exit Sub
Else
If Range("STORE_RECORDS[CHECKED OUT on its way to analytical lab]").Find(Code, , , xlWhole, , xlPrevious) Is Nothing Then MsgBox ("No match, ask Carlos !"): Exit Sub
Range("STORE_RECORDS[CHECKED OUT on its way to analytical lab]").Find(Code, , , xlWhole, , xlPrevious).Offset(0, 2) = Code
Range("STORE_RECORDS[CHECKED OUT on its way to analytical lab]").Find(Code, , , xlWhole, , xlPrevious).Offset(0, 3) = Now
End If
End Sub
Here is a preview of what my template looks like, set up in table format.
|
|
|
|
<tbody> </tbody> <tbody> </tbody> | |||||||||||||||||||||||||
4655-003-1 | 4/17/2019 14:20 | 4355-007-110 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-10 | 4/17/2019 14:20 | 4355-007-117 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-11 | 4/17/2019 14:20 | 4355-007-118 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-12 | 4/17/2019 14:20 | 4355-007-119 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-13 | 4/17/2019 14:20 | 4355-007-121 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-14 | 4/17/2019 14:20 | 4355-007-122 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-15 | 4/17/2019 14:20 | 4355-007-123 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-16 | 4/17/2019 14:20 | 4355-007-124 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-17 | 4/17/2019 14:20 | 4355-007-125 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-18 | 4/17/2019 14:20 | 4355-007-126 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-19 | 4/17/2019 14:20 | 4355-007-127 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-20 | 4/17/2019 14:20 | 4355-007-128 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-6 | 4/17/2019 14:20 | 4355-007-113 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-7 | 4/17/2019 14:20 | 4355-007-114 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-8 | 4/17/2019 14:20 | 4355-007-115 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-9 | 4/17/2019 14:20 | 4355-007-116 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-21 | 4/18/2019 12:45 | 4355-007-129 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-22 | 4/18/2019 12:45 | 4355-007-131 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-23 | 4/18/2019 12:45 | 4355-007-132 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-24 | 4/18/2019 12:45 | 4355-007-133 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-25 | 4/18/2019 12:45 | 4355-007-134 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-26 | 4/18/2019 12:45 | 4355-007-135 | 4/23/2019 11:30 | ||||||||||||||||||||||||||
4655-003-27 | 4/18/2019 12:45 | 4355-007-137 | |||||||||||||||||||||||||||
4655-003-28 | 4/18/2019 12:45 | 4355-007-138 |
<tbody>
</tbody>