A
Animal via OfficeKB.com
Hi there,
I would like to use two object variables that holds two seperate values, but
I don't seem to get it to work. The object variable seems to change as soons
as the other object gets a value. Why? I have to work with two different
values.
I simplified my code to demonstrate:
Dim c as object
Dim d as object
Set c = Range("A1:A10").Find(10, LookIn:=xlValues)
Set d = Range("B1:B10").Find(2, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Set c = Range("A1:A10").FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
--------------------------------------------------
Here is my real code. I get an error when I come to the loop while and the
currentMonth assigns the d-value........
I need to work with both the objects, how?.
Dim currentMonth as object
Dim d as object
Set currentMonth = Range("StartMonth:EndMonth").Find(Range("ReportMonth"),
LookIn:=xlValues)
Set d = Range("Year", currentMonth.Offset(-1, 0)).Find(Range("ReportYear"),
LookIn:=xlValues)
If Not currentMonth Is Nothing Then
firstAddress = currentMonth.Address
Do
If Not d Is Nothing Then
FormatCurrentMonth
Else
Set currentMonth = Range("StartMonth:EndMonth").FindNext
(currentMonth)
Loop While Not currentMonth Is Nothing And firstAddress <>
currentMonth.Address
End If
Could someone maybe help me.
I could be working with strings instead of objects, but I don't know how when
I want to use the find method.
Take care,
I would like to use two object variables that holds two seperate values, but
I don't seem to get it to work. The object variable seems to change as soons
as the other object gets a value. Why? I have to work with two different
values.
I simplified my code to demonstrate:
Dim c as object
Dim d as object
Set c = Range("A1:A10").Find(10, LookIn:=xlValues)
Set d = Range("B1:B10").Find(2, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Set c = Range("A1:A10").FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
--------------------------------------------------
Here is my real code. I get an error when I come to the loop while and the
currentMonth assigns the d-value........
I need to work with both the objects, how?.
Dim currentMonth as object
Dim d as object
Set currentMonth = Range("StartMonth:EndMonth").Find(Range("ReportMonth"),
LookIn:=xlValues)
Set d = Range("Year", currentMonth.Offset(-1, 0)).Find(Range("ReportYear"),
LookIn:=xlValues)
If Not currentMonth Is Nothing Then
firstAddress = currentMonth.Address
Do
If Not d Is Nothing Then
FormatCurrentMonth
Else
Set currentMonth = Range("StartMonth:EndMonth").FindNext
(currentMonth)
Loop While Not currentMonth Is Nothing And firstAddress <>
currentMonth.Address
End If
Could someone maybe help me.
I could be working with strings instead of objects, but I don't know how when
I want to use the find method.
Take care,