Thread: rng propblem
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Patrick C. Simonds Patrick C. Simonds is offline
external usenet poster
 
Posts: 343
Default rng propblem

The first 2 lines of code below

What I am wondering is if the code below could be modified in some way to
where as it finds the first occurrence of NoXXX if assigns the variable rng1
and then Set rng1 = Cells(ActiveCell.Row, 1), and then loop to the next
occurrence of NoXXX and set it as rng2 ect.

There can be up to 10 occurrences of NoXXX in column AA. The other part of
the problem is that the last occurrence must be called rng. So if there was
only 1 occurrence of NoXXX it would have to be called rng.

All of this is then used to populate my UserForm with information from each
of the lines.


Sub NextRow()
'
' Macro4 Macro
'

'This routine finds each occurance of NoXXX in column AA so that multipage 2
of NoShowDataInput UserForm can display prior No Shows

Dim c As Range

On Error GoTo Done

ActiveSheet.Columns("AA").Hidden = False

Set c = Cells.Find(What:="NoXXX", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False)

If Not c Is Nothing Then
If Intersect(c, Union(Rows("1:" & (ActiveCell.Row + _
(ActiveCell.Row < 1))), Range("A" & _
ActiveCell.Row & ":" & ActiveCell.Address))) _
Is Nothing Then
c.Select

Else

End If
End If

Done:
ActiveSheet.Columns("AA").Hidden = True

End Sub