• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 409
  • Last Modified:

cell address in rng not working

excel 2003 vba

I code that should be picking a cell.value for a range...

but not taking the value:

Set rng = Range(Target.Address)  

For Each cell In rng
       xsearch = "SELECT AlternatesPL.ALT FROM AlternatesPL Where AlternatesPL.Item=""" & cell.Value & """;"
in this case the target.address  could be "I19"

cell.value is coming up as nothing.

  • 2
  • 2
1 Solution
NorieData ProcessorCommented:
Where does Target come from?

PS If Target is a range you could just use Set rng = Target, or even use Target in the For Each.
FordraidersAuthor Commented:
Private Sub xlApp_SheetChange(ByVal Sh As Object, ByVal Target As Range)

being passed...this is an add-in app,
NorieData ProcessorCommented:
Why not try just using Target like I suggested.
Set rng = Target

Open in new window

This will ensure that you are looking at the correct range on the correct sheet.

With the original code you would have been looking at the correct range on the active sheet, which might not be the correct sheet.
FordraidersAuthor Commented:
perfect Thanks

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now