Consulting

Results 1 to 10 of 10

Thread: Solved: Find Text Position

  1. #1

    Solved: Find Text Position

    hello guys,

    I have made some changes to a VB code that I found on this forum, it works great, but for some reason that I cannot understand it stops at Rws=16,

    please find details in the attachement. the macro runs from VALUE, insert in the first MSGBOX "data", in the 2nd bottom and in the 3rd "VALUE"


    Attachment 3958


    Thanks

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What is the For i ... Next loop after the output sheet name supposed to be doing?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    It is for setting the Cell where I want the output (R.ROW, R.COlumn) written.

    Cheers

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Doesn't make any sense to me, I would expect something along these lines

    [vba]

    Sub FindIt()
    Dim FindAddress As String
    Dim R As Range
    Dim DelRange As Range
    Dim Rws As Integer
    Dim i As Integer
    Dim DestWb As Workbook
    Dim DestWs As Worksheet
    Dim Tempbook As Workbook

    Sheets(InputBox("Enter DATA SheetName:", "Inputbox")).Select

    With Range("a2:i1000")

    Set R = .Find(InputBox("Enter WORD to Look for:", "Inputbox"))

    If Not R Is Nothing Then

    FindAddress = R.Address
    Sheets(InputBox("Enter OUTPUT SheetName:", "Inputbox")).Select
    Do

    i = i + 1
    Cells(i, 1) = R.Row
    Cells(i, 2) = R.Column
    Set R = .FindNext(R)
    Loop While Not R Is Nothing And R.Address <> FindAddress
    End If
    End With
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,874
    Also it's worth being aware of the following:
    The .find method has arguments that you can pass to it; from help:
    .Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat)
    The settings for LookIn, LookAt, SearchOrder, and MatchByte are saved each time you use this method. If you don’t specify values for these arguments the next time you call the method, the saved values are used.

    In this case you may only need to set LookIn and LookAt explicitly.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  6. #6
    Thanks guys, as I said in a previous post I am a newbee on VB and I learn as I go.

    thanks again

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    So, are you sorted?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    XLD

    sorry for late reply, one more question:

    in your code How "i" know where to start and where to finish?

    cheers

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It is just a counter, it starts initialised at 0 and gets incremented for every found record.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  10. #10
    Ok then, I have used p45cal suggestion and i can narrow down the search.

    Issue is solved.


    thanks for help

Posting Permissions

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