Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I could be misunderstanding what you are looking for. If you Dim the variable as Range, then set that variable to equal a range object, the variable is in effect a range object. The value of the object and it's data type will be subject to the content of the range. What are you expecting the data type to be? "maweilian" wrote in message ... I have tried what you suggested below but the line: "oldshearvalue = Range(myRange.Item(1).Address)" still seems to be returning a Double and not a Range object. Public Function maxmoment(myRange As Range) Dim shearvalue, oldshearvalue, momentvalue1, momentvalue2, maxmomentvalue, maxmomentvalues(), index As Long, currentmax As Double oldshearvalue = Range(myRange.Item(1).Address) For Each shearvalue In myRange.Cells If oldshearvalue.Value * shearvalue.Value < 0 Then momentvalue1 = oldshearvalue.Offset(0, -1) momentvalue2 = shearvalue.Offset(0, -1) If momentvalue1 momentvalue2 Then maxmomentvalue = momentvalue1 Else maxmomentvalue = momentvalue2 End If ReDim Preserve maxmomentvalues(UBound(maxmomentvalues) + 1) maxmomentvalues(UBound(maxmomentvalues)) = maxmomentvalue End If oldshearvalue = shearvalue Next For index = LBound(maxmomentvalues) To UBound(maxmomentvalues) If maxmomentvalues(index) currentmax Then currentmax = maxmomentvalues(index) End If Next index maxmoment = currentmax End Function "JLGWhiz" wrote: That actually only returns a string for the cell. You would have to use: Range(var1) = 'something as a range object. "maweilian" wrote in message ... Another newbie question: For the following: Dim myRange as Range, var1 var1 = myRange.Item(1) MyRange.Item(1) returns a Variant/Double. How can I get it to return a range object representing a single cell? Thanks, Will |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
drop first row in range and return a new range object | Excel Programming | |||
returning pivottable object from a range object | Excel Programming | |||
Range object to Array object conversion | Excel Programming | |||
Range object to Array object conversion | Excel Programming | |||
Range object to Array object conversion | Excel Programming |