Results 1 to 12 of 12

Sub Or Function not Defined ('Worksheet' not working as intended)

Threaded View

  1. #1
    Registered User
    Join Date
    12-27-2021
    Location
    Australia
    MS-Off Ver
    2021
    Posts
    9

    Question Sub Or Function not Defined ('Worksheet' not working as intended)

    Its been a long time since i tried VB in excel and i followed this ladies tutorial on youtube (Use Barcodes in Excel to track in and outs - Barb Henderson, 2019 [Youtube]). I copied everything and adjusted it to fit my sheets but I don't know why this error keeps occurring on this line.
    _______________________________________________________________________________

    Sub checkin()
    Dim barcode As String
    Dim rng As Range
    Dim rownumber As Long
    
    
    barcode = Worksheet("Sheet4").Cells(1, 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 = "d/m/yyyy h:mm AM/PM"
            Worksheets("Sheet4").Cells(1, 2) = ""
        End If
    End Sub
    ________
    _______________________________________________________________________

    The error I am getting is "Compile error: Sub or Function not defined" It then highlights the word Worksheet in the yellow line.


    image_2021-12-28_032933.png
    Last edited by aZileanWays2Die; 12-27-2021 at 02:24 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] IF OR statement not working as intended
    By chris01395 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-27-2020, 09:50 AM
  2. VBA function not working as intended- Loop Problem?
    By KrombopulosMichael in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-27-2018, 05:50 PM
  3. PowerPivot not working as intended?
    By fingerstyle in forum Excel General
    Replies: 11
    Last Post: 10-22-2017, 08:35 PM
  4. [SOLVED] Msgbox not working as intended
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-24-2013, 09:12 AM
  5. [SOLVED] Nested if formula not working as intended
    By Reibie in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-11-2013, 05:59 AM
  6. [SOLVED] VLOOKUP not working as intended
    By RAS 2112 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-12-2013, 08:58 AM
  7. [SOLVED] macro not working as intended
    By Michael A in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-06-2005, 10:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1