Closed Thread
Results 1 to 4 of 4

FiX the VBA code

  1. #1
    Registered User
    Join Date
    07-05-2020
    Location
    JERUSALEM
    MS-Off Ver
    2016
    Posts
    30

    FiX the VBA code

    Hello everybody
    below is the code ready to use
    need to be fixed please

    one problem is that you have to enter manually every time range of values you are looking for
    and i need it to check range of values row by row automatically untill the table is ended

    another problem is that the code returns the answer as value on the screen box and i need it to enter the value near the row which was checked right now and to continue to another row and so on until the table is ended.
    the code works perfect on excel 2007
    thank you everybody


    Sub LoopUntilSpecificValue()
    'UpdatebyExtendoffice20161222
    Dim fStr As String
    Dim strActAddress As String
    Dim fbool As Boolean
    Dim cnt As Long, cntRow As Long
    Dim xRg As Range, yRg As Range, zRg As Range
    fbool = False
    strActAddress = ""
    cnt = 0
    On Error Resume Next
    Set zRg = ActiveSheet.UsedRange
    cntRow = zRg.Rows.Count

    Set xRg = Application.InputBox _
    (Prompt:="Range select..", Title:="Kutools for Excel", Type:=8)
    fStr = Application.InputBox _
    (Prompt:="Search string?", Title:="Kutools for Excel", Type:=2)
    Application.ScreenUpdating = False
    For Each yRg In xRg

    If yRg.Row > cntRow Then
    MsgBox "Value not found ", vbInformation, "Kutools for Excel"
    Application.ScreenUpdating = True
    Exit Sub
    End If
    If yRg.Value2 = fStr Then
    Application.ScreenUpdating = True
    yRg.Activate
    fbool = True
    strActAddress = yRg.Address
    MsgBox "Value found in cell " & strActAddress, vbInformation, "Kutools for Excel"

    Exit Sub
    Else
    cnt = cnt + 1
    End If

    Next yRg

    If cnt = xRg.Count Then
    MsgBox "Value not found ", vbInformation, "Kutools for Excel"
    End If
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: FiX the VBA code

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here


    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,980

    Re: FiX the VBA code

    Administrative Note:

    We would very much like to help you with your query, however the thread title does not really convey what your request is about. Tell us what you are trying to do, not how you think it should be done.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)

    Administrative Note:

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,980

    Re: FiX the VBA code

    As you clearly have no intention whatsoever of following our rules, I am closing this thread.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Code to display text & code in a combo list, but display only code when selected
    By kdestef1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-26-2019, 06:07 PM
  2. [SOLVED] Need help with VBA code. Tons of code seperated in two, second part of code doesn't work.
    By FragaGeddon in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 11-30-2015, 11:46 AM
  3. [SOLVED] Pattern Building VBA Code - Working code, would like to use cleaner code
    By Benisato in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-10-2015, 03:05 PM
  4. [SOLVED] Excel VB code. Message pops up while code running asking question. Code must not wait.
    By Heinrich Venter in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-28-2014, 06:10 AM
  5. [SOLVED] VBA code for assigning a numeric code to text; then numeric code populates table
    By cteaster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2014, 08:01 PM
  6. Replies: 2
    Last Post: 03-09-2013, 04:30 AM

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