Results 1 to 10 of 10

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

Threaded View

  1. #1
    Registered User
    Join Date
    11-07-2016
    Location
    UK
    MS-Off Ver
    2010
    Posts
    11

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

    I have managed to create a fairly complex (for me) macro using chat.openAI that searches to find a column then find all partial matching cells then copies those cells plus other cells to a different sheet.

    But this simple one has beat me or beat openAI.

    EDIT - SEE MY LATER POST with attached .xlsm with macro


    The macro:
    Sub FindKeyword()
    Dim KWsearch As String
    KWsearch = ActiveCell.Value

    Dim keywordSheet As Worksheet
    Set keywordSheet = ThisWorkbook.Worksheets("Keyword")
    keywordSheet.Activate

    Dim lastRow As Long
    lastRow = keywordSheet.Cells(keywordSheet.Rows.Count, "A").End(xlUp).Row

    Dim keywordListColumn As Long
    keywordListColumn = 0

    Dim i As Long
    For i = 1 To keywordSheet.Columns.Count
    If keywordSheet.Cells(1, i).Value = "keyword list" Then
    keywordListColumn = i
    Exit For
    End If
    Next i

    For i = 2 To lastRow
    If keywordSheet.Cells(i, keywordListColumn).Value = KWsearch Then
    ' Found a match!
    keywordSheet.Cells(i, keywordListColumn).Activate
    keywordSheet.Parent.VerticalScrollBar.Value = _
    keywordSheet.Cells(i, keywordListColumn).Top - keywordSheet.Parent.Height / 2
    Exit For
    End If
    Next i
    End Sub

    ===========
    My instructions to OpenAI (excluding the scroll part of the macro - mentioned earlier in the chat

    I have a workbook with a sheet named "Keyword"
    The "Keyword" sheet has a column where the title = "Keyword List"
    The macro needs to find that Column and save it's location.

    The user selects a cell in any other sheet. The cell becomes the ActiveCell for that sheet.
    Save the value in that cell as "KWsearch"

    When the user runs the macro it does the following:
    Make "Keyword" shee the ActiveSheet
    Search all cells in the "Keyword List" column
    When a matching cell is found
    Make it the "ActiveCell" in the "Keyword" sheet.

    ===========
    When run the macro makes the "Keyword" sheet the ActiveSheet, but the previously ActiveCell is still active.
    There is no error popup
    ===========

    I have no previous with StepInto, but when I click this and press > play, it does the same as run - makes Keyword sheet active.

    I expected StepInto to highlight and run the code one line at a time but nothing happens in the code window.

    =====
    Any help would be appreciated

    ColinK2
    Last edited by colink2; 12-24-2022 at 08:34 PM.

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