Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Defining a range in vba???? Please help
I have multiple ranges in a spreadsheet. The problem is I want to define
them, and use them in a function in vba. I do not want the cells that are zero or smaller to be included in the range when the range is being used in the function. I was wondering if it is possible to say like if range(A1:B200) 0 then range(A1:B200) = rngtemp. Can someone help? Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Defining a range in vba???? Please help
Sub range_reducer()
Dim r1 As range, r2 As range Set r1 = range("A1:B200") Set r2 = Nothing For Each r In r1 If r.Value 0 Then If r2 Is Nothing Then Set r2 = r Else Set r2 = Union(r, r2) End If End If Next MsgBox (r2.Address) End Sub Starting with r1, we build r2 to contain only the positives. -- Gary''s Student gsnu200711 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Defining a range in vba???? Please help
Sweet. Thank you very much.
"Gary''s Student" wrote: Sub range_reducer() Dim r1 As range, r2 As range Set r1 = range("A1:B200") Set r2 = Nothing For Each r In r1 If r.Value 0 Then If r2 Is Nothing Then Set r2 = r Else Set r2 = Union(r, r2) End If End If Next MsgBox (r2.Address) End Sub Starting with r1, we build r2 to contain only the positives. -- Gary''s Student gsnu200711 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Defining series range for named range | Excel Programming | |||
defining a range | Excel Programming | |||
Defining a range for a look up | Excel Programming | |||
Defining a Range | Excel Programming | |||
Defining a range | Excel Programming |