From: David on
Hi Group,

I have something very strange happening, that I can not explain. I have 2
variables:

TotalValue = ActiveCell.Offset(16, 0).Value
(Gets set to 102,000, which is a correct value.)
TargetTotal = ActiveCell.Offset(64, 0).Value
(Gets set to 35000, which is a correct value, BUT TotalValue becomes 35,000)

I am not sure what I am missing in this process. Can anyone tell me why this
would happened.

Thanks,
--
David
From: AB on
I'd think that people here will ask for a bit more of your code to
tell where the problem is.
From the top of my head the first reason that would come to my mind is
that somewhere in your code you're passing your variable (TotalValue)
ByRef and not ByVal and that makes the two variables being pretty much
one variable (when one changes, so does the other.
From: EricG on
It might help if you shows us more of the code surrounding those two
statements...

Eric

"David" wrote:

> Hi Group,
>
> I have something very strange happening, that I can not explain. I have 2
> variables:
>
> TotalValue = ActiveCell.Offset(16, 0).Value
> (Gets set to 102,000, which is a correct value.)
> TargetTotal = ActiveCell.Offset(64, 0).Value
> (Gets set to 35000, which is a correct value, BUT TotalValue becomes 35,000)
>
> I am not sure what I am missing in this process. Can anyone tell me why this
> would happened.
>
> Thanks,
> --
> David
From: David on
Hi,

There is a lot of code, what difference do you think it would make? These 2
lines follow each other, one right after the other. The code is about 11
pages when copied into Word. These lines appear about 5 pages into the Module.

They are one statement right after the other:
TotalValue = ActiveCell.Offset(16, 0).Value
TargetTotal = ActiveCell.Offset(64, 0).Value

The first line ends with a correct value. After the second line runs, it has
a correct value in TargetTotal, but TotalValue has changed to the value of
TargetTotal. In other words they are now both the same value.

As I step through the code, which I have done several times, the opposite
also happens:

TotalValue = ActiveCell.Offset(16, 0).Value
(Captures correct amount, but changes the value of TargetTotal, before the
line is even run and puts the value of TotalValue in it)

TargetTotal = ActiveCell.Offset(64, 0).Value
(Changes the value of BOTH variable to the value of TargetTotal)

It is not complicated code, but I sure can not explain it.

Thanks,
--
David


"EricG" wrote:

> It might help if you shows us more of the code surrounding those two
> statements...
>
> Eric
>
> "David" wrote:
>
> > Hi Group,
> >
> > I have something very strange happening, that I can not explain. I have 2
> > variables:
> >
> > TotalValue = ActiveCell.Offset(16, 0).Value
> > (Gets set to 102,000, which is a correct value.)
> > TargetTotal = ActiveCell.Offset(64, 0).Value
> > (Gets set to 35000, which is a correct value, BUT TotalValue becomes 35,000)
> >
> > I am not sure what I am missing in this process. Can anyone tell me why this
> > would happened.
> >
> > Thanks,
> > --
> > David
From: AB on
How are the
TotalValue
TargetTotal
dimensioned? (i.e. declared with Dim statment)