HELP PLEASE

Jcjepot

New Member
Joined
Oct 5, 2021
Messages
12
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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
52,345
Office Version
  1. 365
Platform
  1. Windows
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. :)
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,392
Messages
5,769,807
Members
425,573
Latest member
AmroK

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
Top