Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Object variable or with block not set


Hi,

im trying to make a small vba application in excell to manage all of my
compagny's finances. I just got started, i only got 2 user forms up to
now, the first form lists all clients and the second one will show all
the informations on the client selected in the first form. When i load
the next form, everything is sweet, but when i started putting code in
the UserForm_Initialize() method, i started to get runtime error 91
Object variable or with block not set. Ill post the code that i think
is relevant and i would really appreciate some of ur help.

_in_the_first_form_
Private Sub cmdSuivant_Click()
paramClient = Mid(lstClients, 1, InStr(1, lstClients, " ",
vbTextCompare))

Unload Me
Load frmClient
frmClient.Show
End Sub

_in_the_second_form_
Private Sub UserForm_Initialize()
Dim lign As Integer
Dim lRange As Range

Set lRange = Sheet4.Range("A4:A500")

lign = lRange.Find(paramClient).row
msgbox lign
End Sub

_in_a_module_
Public paramClient As String

i think the error is related to the lign = lRange.Find(paramClient).row
because if i put it in comment, everything is nice.

I would really appreciate ur help
Thanks


--
Benny5788
------------------------------------------------------------------------
Benny5788's Profile: http://www.excelforum.com/member.php...o&userid=24975
View this thread: http://www.excelforum.com/showthread...hreadid=386132

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Object variable or with block not set

That error means you haven't found the paramClient in the range lrange.
Find returns "nothing" when it doesn't find the target. Then when you do

lign = Nothing.row

you get the error you describe.

What you need to do is

set lRange1 = lRange.Find(paramClient)
if lRange1 is nothing then
msgbox "Not Found"
Else
msgbox lRange1.Row
End if

--
Regards,
Tom Ogilvy



"Benny5788" wrote in
message ...

Hi,

im trying to make a small vba application in excell to manage all of my
compagny's finances. I just got started, i only got 2 user forms up to
now, the first form lists all clients and the second one will show all
the informations on the client selected in the first form. When i load
the next form, everything is sweet, but when i started putting code in
the UserForm_Initialize() method, i started to get runtime error 91
Object variable or with block not set. Ill post the code that i think
is relevant and i would really appreciate some of ur help.

_in_the_first_form_
Private Sub cmdSuivant_Click()
paramClient = Mid(lstClients, 1, InStr(1, lstClients, " ",
vbTextCompare))

Unload Me
Load frmClient
frmClient.Show
End Sub

_in_the_second_form_
Private Sub UserForm_Initialize()
Dim lign As Integer
Dim lRange As Range

Set lRange = Sheet4.Range("A4:A500")

lign = lRange.Find(paramClient).row
msgbox lign
End Sub

_in_a_module_
Public paramClient As String

i think the error is related to the lign = lRange.Find(paramClient).row
because if i put it in comment, everything is nice.

I would really appreciate ur help
Thanks


--
Benny5788
------------------------------------------------------------------------
Benny5788's Profile:

http://www.excelforum.com/member.php...o&userid=24975
View this thread: http://www.excelforum.com/showthread...hreadid=386132



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime Error '91' Object variable or With block variable not set Alec Coliver Excel Discussion (Misc queries) 2 October 24th 09 02:29 PM
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
Error 91 -- Object variable or With block variable not set Rachael[_3_] Excel Programming 2 November 22nd 04 02:59 PM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM
Pivot Table - Object variable or with block variable not set? George Nicholson[_2_] Excel Programming 1 April 16th 04 09:12 PM


All times are GMT +1. The time now is 11:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"