View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Newbie with VBA for Excel

If NumDpt isn't in A4:F20, then the .find fails. And if the .find fails, then
there's no .address. And then KABLEWIE!

One way around it:

dim myCell as range
dim Colonne as string
set mycell = ClasseurRepresentants.Sheets(1).Range("A4:F20") _
.Find(What:=NumDpt, LookIn:=xlFormulas, LookAt:=xlWhole)

if mycell is nothing then
colonne = "not found!
else
colonne = mycell.address
end if




echo---pscbro wrote:

Hi,

Can anyone help me out with the integrity of this line (on execution,
Excel says "Object or bloc variable not defined"). However I have set
Option Explicit in my own learning session of VBA and it all my
variables have been declared. See line below:

Colonne =
ClasseurRepresentants.Sheets(1).Range("A4:F20").Fi nd(What:=NumDpt, _
LookIn:=xlFormulas, LookAt:=xlWhole).Address

Thanks in advance,

Pascal


--

Dave Peterson