Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Range / VBA
Can you set a range that's conditional on the contents of a cell ? e.g. where column C contains "Fred" you'd have only the "Fred"s. And would it include all the other columns in the rows? Thanks - Kirk |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Range / VBA
You could try:
Sub test() Dim rngFound As Range Dim rngFred As Range Dim strFirst As String With Range("C:C") Set rngFound = .Find(what:="Fred", _ after:=.Range("A1"), _ LookIn:=xlValues, _ lookat:=xlWhole, _ searchorder:=xlByColumns, _ searchdirection:=xlNext, _ MatchCase:=False, _ matchbyte:=False) If Not rngFound Is Nothing Then strFirst = rngFound.Address Set rngFred = rngFound Do Set rngFound = .FindNext(rngFound) If rngFound.Address < strFirst Then _ Set rngFred = Union(rngFred, rngFound) Loop Until rngFound.Address = strFirst End If End With If Not rngFred Is Nothing Then _ Set rngFred = rngFred.EntireRow MsgBox rngFred.Address End Sub "kirkm" wrote: Can you set a range that's conditional on the contents of a cell ? e.g. where column C contains "Fred" you'd have only the "Fred"s. And would it include all the other columns in the rows? Thanks - Kirk |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Range / VBA
Many thanks. Given me heaps to work from.
Cheers - Kirk |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I enter formula sum(range+range)*0.15 sumif(range=3) | Excel Discussion (Misc queries) | |||
Excel Addin:Setting the range to the Excel.Range object range prop | Excel Worksheet Functions | |||
Range Question / error 1004: method Range of object Worksheet has failed | Excel Programming | |||
Range.Find returns cell outside of range when range set to single cell | Excel Programming | |||
how to? set my range= my UDF argument (range vs. value in range) [advanced?] | Excel Programming |