HELP PLEASE

Jcjepot

New Member
Joined
Oct 5, 2021
Messages
13
Office Version
  1. 365
Platform
  1. Windows
i have the following macro

VBA Code:
Sub inout()
Dim barcode As String
Dim rng As Range
Dim rownumber As Long

barcode = Worksheets("Sheet1").Cells(2, 2)

    Set rng = Sheet1.Columns("a:a").Find(What:=barcode, _
    LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    If rng Is Nothing Then
        ActiveSheet.Columns("a:a").Find("").Select
        ActiveCell.Value = barcode
        ActiveCell.Offset(0, 1).Select
        ActiveCell.Value = Date & " " & Time
        ActiveCell.NumberFormat = "m/d/yyyy h:mm AM/PM"
        Worksheets("Sheet1").Cells(2, 2) = ""
    Else
        rownumber = rng.Row
        Worksheets("Sheet1").Cells(rownumber, 1).Select
        ActiveCell.Offset(0, 2).Select
        ActiveCell.Value = Date & " " & Time
        ActiveCell.NumberFormat = "m/d/yyyy h:mm AM/PM"
        Worksheets("Sheet1").Cells(2, 2) = ""
       
    End If
Worksheets("Sheet1").Cells(2, 2).Select
End Sub


Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("B2")) Is Nothing Then
        Application.EnableEvents = False
        Call inout
        Application.EnableEvents = True
    End If
   
End Sub

,, basically , i want to add another 3 rows above. the cells would be changed.

Barcode will be in B5 and the data will be starting in A6 . I cant figure out where to change.
 
Last edited by a moderator:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
When posting vba code, please use the available code tags to preserve formatting and make it easier for helpers to read and debug. My signature block below has more information. I have fixed it for you this time. :)
 
Upvote 0

Forum statistics

Threads
1,213,506
Messages
6,114,027
Members
448,543
Latest member
MartinLarkin

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