View Full Version : Solved: Find Text Position
fabio.geraci
06-28-2010, 03:42 AM
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"
3958
Thanks
Bob Phillips
06-28-2010, 03:53 AM
What is the For i ... Next loop after the output sheet name supposed to be doing?
fabio.geraci
06-28-2010, 03:56 AM
It is for setting the Cell where I want the output (R.ROW, R.COlumn) written.
Cheers
Bob Phillips
06-28-2010, 04:18 AM
Doesn't make any sense to me, I would expect something along these lines
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
p45cal
06-28-2010, 04:46 AM
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.
fabio.geraci
06-28-2010, 05:02 AM
Thanks guys, as I said in a previous post I am a newbee on VB and I learn as I go.
thanks again
Bob Phillips
06-28-2010, 05:03 AM
So, are you sorted?
fabio.geraci
06-28-2010, 11:49 PM
XLD
sorry for late reply, one more question:
in your code How "i" know where to start and where to finish?
cheers
Bob Phillips
06-28-2010, 11:53 PM
It is just a counter, it starts initialised at 0 and gets incremented for every found record.
fabio.geraci
06-29-2010, 03:12 AM
Ok then, I have used p45cal suggestion and i can narrow down the search.
Issue is solved.
thanks for help
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.