Results 1 to 10 of 10

Please help debug this simple macro - created with chat.openAI

Threaded View

  1. #9
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,935

    Re: Please help debug this simple macro - created with chat.openAI

    Option Explicit
    Sub FindKeyword()
        Dim keywordSheet        As Worksheet, _
            ACTSHT              As Worksheet, _
            KeyWordListColumn   As Variant, _
            KWMatch             As Variant, _
            lastKeyWord         As Long, _
            VisibleCols         As Long, _
            VisibleRows         As Long, _
            KWsearch            As String
        
        Set ACTSHT = ActiveSheet
        KWsearch = ActiveCell.Value
        If IsEmpty(ActiveCell) Then
            MsgBox "no word chosen"
            Exit Sub
        End If
    
        Set keywordSheet = ThisWorkbook.Worksheets("Keyword")
        keywordSheet.Activate
        Set KeyWordListColumn = Range("1:1").Find("keyword list")
        lastKeyWord = KeyWordListColumn.End(xlDown).Row
        Set KeyWordListColumn = KeyWordListColumn.Resize(rowsize:=lastKeyWord)
        Set KWMatch = KeyWordListColumn.Find(KWsearch)
        
        If Not KWMatch Is Nothing Then
            VisibleRows = ActiveWindow.VisibleRange.Rows.Count
            VisibleCols = ActiveWindow.VisibleRange.Columns.Count
            Application.Goto _
                Reference:=KWMatch, _
                scroll:=True
            ActiveWindow.SmallScroll _
                Toleft:=VisibleCols \ 2
            ActiveWindow.SmallScroll _
                up:=VisibleRows \ 2
    Else
            MsgBox KWsearch & vbCrLf & _
            " was not found"
        End If 'match
    End Sub
    Last edited by protonLeah; 12-25-2022 at 01:11 AM.
    Ben Van Johnson

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Introducing a dynamic heading to created PDF Files created by macro
    By Romoluzzi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-17-2020, 05:42 AM
  2. Pivot Table Macro - Debug Error: Created in 2016 and works, does not work in Excel 2013
    By ashley72788 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-05-2017, 04:07 AM
  3. Macro to review chat log
    By amit6488 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-29-2015, 07:05 AM
  4. Live chat/chat room
    By SChapman in forum Suggestions for Improvement
    Replies: 1
    Last Post: 05-06-2013, 10:05 PM
  5. Read simple random file created with another for of Basic
    By Petrus Vorster in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-30-2012, 10:49 AM
  6. [SOLVED] Pivot Chat Macro
    By Rastus in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-20-2006, 10:50 AM
  7. [SOLVED] simple (i think) UDF debug help needed
    By Adam Kroger in forum Excel General
    Replies: 4
    Last Post: 12-18-2005, 04:15 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