vb.net - Type mismatch for Shape variable in VB -


i trying go through each commandbutton on worksheet. keep getting type mismatch error when try run function. dont know mistake making here. please me.

sub worksheet_calculate()   dim s shape dim findshape string  findshape = "not found"  each s in me.shapes     if intersect(s.topleftcell.address, range("d8:d21,d52:d64,d107:d117")) = true       findshape = s.name         msgbox findshape, vbokonly         else         msgbox "the active cell intersect "       end if next 

you not using intersect correctly. intersect returns range intersection of 2 other ranges. if want know 2 ranges have in common, check result not nothing. do:

dim s shape dim findshape string  findshape = "not found" each s in me.shapes     if not intersect(s.topleftcell, range("d8:d21,d52:d64,d107:d117")) nothing         findshape = s.name         msgbox findshape, vbokonly     else     msgbox "the active cell intersect "      end if next 

note have removed .address topleftcell. intersect works on ranges topleftcell is. address returns string not intersect wants. think error what's causing run time error, although incorrect usage of intersect next.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -