ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   find next? urgent (https://www.excelbanter.com/excel-programming/333059-find-next-urgent.html)

cwatson[_8_]

find next? urgent
 

i need a VBA function that finds the first instance of "a" in
worksheet, performs an operation on it, then does the same for the nex
instance of "a", until the term is no longer found

thnx al

--
cwatso
-----------------------------------------------------------------------
cwatson's Profile: http://www.excelforum.com/member.php...fo&userid=2460
View this thread: http://www.excelforum.com/showthread.php?threadid=38286


cwatson[_9_]

find next? urgent
 

heres what i have so far

Code:
--------------------
Sheets("list").Select
Cells.Find(What:="A-s", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
Application.Run "achip.xls!rawdata"
--------------------


and the paramenter to find next:

Code:
--------------------
Cells.FindNext(After:=ActiveCell).Activate
--------------------


i need to run the first code snippet, then run the second code snippet,
then the first..untill the last occupied column.

:)


--
cwatson
------------------------------------------------------------------------
cwatson's Profile: http://www.excelforum.com/member.php...o&userid=24608
View this thread: http://www.excelforum.com/showthread...hreadid=382865


anilsolipuram[_121_]

find next? urgent
 

Backup the workbook before trying this macro.

I am not sure what you doing using Application.Run "achip.xls!rawdata"

Sub macro()
Dim init_adr As Variant
Sheets("list").Select
Cells.Find(What:="A-s", After:=ActiveCell, LookIn:=xlValues
LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext
MatchCase:=False _
, SearchFormat:=False).Activate
init_adr = ActiveCell.Address
Application.Run "achip.xls!rawdata"
While i = 0

Cells.FindNext(After:=ActiveCell).Activate
If ActiveCell.Address < init_adr Then
Application.Run "achip.xls!rawdata"
Else
i = 1
End If

Wend
End Su

--
anilsolipura
-----------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...fo&userid=1627
View this thread: http://www.excelforum.com/showthread.php?threadid=38286


cwatson[_11_]

find next? urgent
 

thank you, i will try that

!rawdata is the operation that needs to be ran on every instance of
"A-s"

rawdata
Code:
--------------------

Sub rawdata()
'
' rawdata Macro
' create raw data based on chips
'
' Keyboard Shortcut: Ctrl+y
'
b = "A"
ActiveCell.Select
a = ActiveCell.Text
Sheets(CStr(b)).Select
Find_Range(CStr(a), Range("A1:DZ1")).Select

Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
c = "final" + CStr(b)
Sheets(CStr(c)).Paste
Sheets(CStr(c)).Select
ActiveCell.EntireColumn.End(xlUp).Offset(0, 3).Select
Sheets("list").Select

End Sub
--------------------


find_range is another find function


--
cwatson
------------------------------------------------------------------------
cwatson's Profile: http://www.excelforum.com/member.php...o&userid=24608
View this thread: http://www.excelforum.com/showthread...hreadid=382865


cwatson[_13_]

find next? urgent
 

your macro completed the operation then found the next cell, it needs t
repeat the operation of every cell found until it finds no mor

--
cwatso
-----------------------------------------------------------------------
cwatson's Profile: http://www.excelforum.com/member.php...fo&userid=2460
View this thread: http://www.excelforum.com/showthread.php?threadid=38286


cwatson[_10_]

find next? urgent
 

Code
-------------------
Sub foreachA()

For x = 1 To 50

Sheets("list").Select
Cells.Find(What:="A-s", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
Application.Run "achip.xls!rawdata"
Sheets("list").Select
Cells.FindNext(After:=ActiveCell).Activate

Next


End Su
-------------------


"50" needs to be the number of instances of "A-s

--
cwatso
-----------------------------------------------------------------------
cwatson's Profile: http://www.excelforum.com/member.php...fo&userid=2460
View this thread: http://www.excelforum.com/showthread.php?threadid=38286


anilsolipuram[_122_]

find next? urgent
 

Sub macro()
Dim init_adr As Variant
Sheets("list").Select
Cells.Find(What:="A-s", After:=ActiveCell, LookIn:=xlValues, LookAt:=
_
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate
init_adr = ActiveCell.Address
Application.Run "achip.xls!rawdata"
While i = 0
on error resume next
Cells.FindNext(After:=ActiveCell).Activate
if err.description<"" then
err.clear
go to a:
end if
Application.Run "achip.xls!rawdata"
End If

Wend
a:
End Sub


--
anilsolipuram
------------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...o&userid=16271
View this thread: http://www.excelforum.com/showthread...hreadid=382865


cwatson[_12_]

find next? urgent
 

missing an "if", im trying to ID where it belongs..

thank you so much for your assitance...i feel just stupid having taken
a week on this code and am not able to figure out this little thing


--
cwatson
------------------------------------------------------------------------
cwatson's Profile: http://www.excelforum.com/member.php...o&userid=24608
View this thread: http://www.excelforum.com/showthread...hreadid=382865


cwatson[_14_]

find next? urgent
 

removing the last "end if" results in an infinite loo

--
cwatso
-----------------------------------------------------------------------
cwatson's Profile: http://www.excelforum.com/member.php...fo&userid=2460
View this thread: http://www.excelforum.com/showthread.php?threadid=38286


anilsolipuram[_123_]

find next? urgent
 

try this and let me know

Sub macro()
Dim count_cell, init_adr As Variant
Sheets("list").Select
Cells.Find(What:="A-s", After:=ActiveCell, LookIn:=xlValues, LookAt:=
_
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
).Activate
init_adr = ActiveCell.Address
count_cell = count_cell + 1
Sheets("list").Select
While i = 0
Cells.FindNext(After:=ActiveCell).Activate
Sheets("list").Select
If ActiveCell.Address < init_adr Then
Application.Run "achip.xls!rawdata"
Else
i = 1
End If

Wend
MsgBox LCase("NUMBER OF INSTANCES FOUND: ") & count_cell
End Sub


--
anilsolipuram
------------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...o&userid=16271
View this thread: http://www.excelforum.com/showthread...hreadid=382865


cwatson[_15_]

find next? urgent
 

indefinintly ran the operation on one instanc

--
cwatso
-----------------------------------------------------------------------
cwatson's Profile: http://www.excelforum.com/member.php...fo&userid=2460
View this thread: http://www.excelforum.com/showthread.php?threadid=38286


anilsolipuram[_125_]

find next? urgent
 

This should not go infinite loop, try this again and let me know wha
count it gives at the end.


Sub macro09()
Dim count_cell, init_adr As Variant
Sheets("list").Select
Cells.Find(What:="A-s", After:=ActiveCell, LookIn:=xlValues, LookAt:
_
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext
MatchCase:=False _
).Activate
Application.Run "achip.xls!rawdata"
init_adr = ActiveCell.Address
count_cell = count_cell + 1
Sheets("list").Select
While i = 0
Cells.FindNext(After:=ActiveCell).Activate
Sheets("list").Select
If ActiveCell.Address < init_adr Then
count_cell = count_cell + 1
Application.Run "achip.xls!rawdata"
Else
i = 1
End If

Wend
MsgBox LCase("NUMBER OF INSTANCES FOUND: ") & count_cell
End Su

--
anilsolipura
-----------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...fo&userid=1627
View this thread: http://www.excelforum.com/showthread.php?threadid=38286


cwatson[_16_]

find next? urgent
 

1 instance foun

--
cwatso
-----------------------------------------------------------------------
cwatson's Profile: http://www.excelforum.com/member.php...fo&userid=2460
View this thread: http://www.excelforum.com/showthread.php?threadid=38286


anilsolipuram[_128_]

find next? urgent
 

can you provide find_range macro.

I am not sure why it is not working.

It works for me

--
anilsolipura
-----------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...fo&userid=1627
View this thread: http://www.excelforum.com/showthread.php?threadid=38286


cwatson[_17_]

find next? urgent
 

Function Find_Range(Find_Item As Variant, _
Search_Range As Range, _
Optional LookIn As Variant, _
Optional LookAt As Variant, _
Optional MatchCase As Boolean) As Range

Dim c As Range
If IsMissing(LookIn) Then LookIn = xlValues 'xlFormulas
If IsMissing(LookAt) Then LookAt = xlPart 'xlWhole
If IsMissing(MatchCase) Then MatchCase = False

With Search_Range
Set c = .Find( _
What:=Find_Item, _
LookIn:=LookIn, _
LookAt:=LookAt, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=MatchCase, _
SearchFormat:=False)
If Not c Is Nothing Then
Set Find_Range = c
firstAddress = c.Address
Do
Set Find_Range = Union(Find_Range, c)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

End Functio

--
cwatso
-----------------------------------------------------------------------
cwatson's Profile: http://www.excelforum.com/member.php...fo&userid=2460
View this thread: http://www.excelforum.com/showthread.php?threadid=38286


cwatson[_18_]

find next? urgent
 

wee! i got it:
thnx for all ur help and effort

Code
-------------------

Sub foreachA()
Sheets("list").Select
Find_Range("A-s", Cells).Select

Dim cell As Object
Dim count As Integer
count = 0
For Each cell In Selection
count = count + 1
Next cell
cnt = count



For x = 1 To CStr(cnt)
Sheets("list").Select
Cells.Find(What:="A-s", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
Application.Run "achip.xls!rawdata"
Sheets("list").Select
Cells.FindNext(After:=ActiveCell).Activate
Next x



End Sub

-------------------

--
cwatso
-----------------------------------------------------------------------
cwatson's Profile: http://www.excelforum.com/member.php...fo&userid=2460
View this thread: http://www.excelforum.com/showthread.php?threadid=38286



All times are GMT +1. The time now is 10:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com