Hi Mary,
Following should help.
i=0
For Each cell In objWorksheet1.UsedRange
If cell.Value <> objWorksheet2.Range(cell.Address).Value Then
ReDim preserve val(i) ' You should use Redim preserve as the
subscript increases for each mismatch
ReDim preserve Row_No(i)
ReDim preserve Col_No(i)
Val(i) = objWorksheet2.Range(cell.Address).Value
Row_No(i) = objWorksheet2.Range(cell.Address).Row
Col_No(i) = objWorksheet2.Range(cell.Address).Column
i=i+1 'I see problem with your increment, which should be inside
the loop, so i place within the loop
end if
Next
Please let me know if it didnt work for you.
Thanks,
Uday
QTP \ UFT Videos <http://www.youtube.com/user/AnemUday/videos>
QTP Videos Blog <http://qtpftvideos.blogspot.in>
On Wednesday, 28 August 2013 18:04:07 UTC+5:30, Mary wrote:
>
> Hi All
> I am comparing two excel files and i got row and column of mismatched
> cell.
> I need to store that values in array values.
>
> I have used the below code but getting error like subscript out of range.
>
> Dim Val(),Row_No(),Col_No()
> i=0
> For Each cell In objWorksheet1.UsedRange
> If cell.Value <> objWorksheet2.Range(cell.Address).Value Then
> Val(i) = objWorksheet2.Range(cell.Address).Value
> Row_No(i) = objWorksheet2.Range(cell.Address).Row
> Col_No(i) = objWorksheet2.Range(cell.Address).Column
> Next
> i=i+1
>
>
--
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en
---
You received this message because you are subscribed to the Google Groups "QTP
- HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.