LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Find Findnext in selected range

Hi, I am a newbie at find/findnext in selected ranges.
I have tried typing in verbatim the example of findnext code
and receive runtime error 9 Subscript out of range. I would like
to search a set range for the character string "7F", insert 2 rows
beneath, fill Cells with the chrstring "LINUX" and then find
the next "7F". I need to do this 8 times.


My original code was as follows:
Dim x, y, z as Integer
Dim rng1 as Range


Range("B:B").Find(what:="3000").Activate
y = ActiveCell.row
Range("B:B").Find(what:="3792").Activate
z = ActiveCell.row


With ActiveSheet
Set rng1 = Range(Cells(y,2),Cells(z,2))
End With


rng1.Find(what:="7F").Activate
For x = 1 to 8


Rows(z + 1 & ":" & z + 2).Insert
Range(Cells(z + 1, 4, Cells(z + 2, 4)) = "LINUX"
ActiveSheet.rng1.FindNext(after:=ActiveCell).Activ ate
z = Activecell.Row
Next x
End Sub

This failed on the FindNext line, so I researched this google group
and found similar code as in the VBA HELP Dialog box and
tested the following code to see if it would work. Thats
when I received the Subscript out of range.


With ActiveSheet.Range("e6:e28")
Set c = .Find("7F", lookin:=x1Values)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Set c = .FindNext(c)
Loop While Not c is Nothing And c.Address < firstAddress
End If
End With


Neither code worked for me. Can anyone tell where I am going
wrong with the code? Much appreciated.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Findnext Noemi Excel Discussion (Misc queries) 1 December 12th 05 11:23 AM
Find, Findnext VBA Loop SMS - John Howard Excel Programming 5 November 13th 04 03:19 AM
FindNext John Keturi Excel Programming 1 October 16th 04 01:56 PM
how to find last row/col index within a selected range Jeff Excel Programming 2 October 6th 04 03:58 PM
Find...FindNext Problem mtsark Excel Programming 4 August 19th 04 04:09 PM


All times are GMT +1. The time now is 06:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"