vba excel error 1004

it stops in a range.find sentence

Page 1 of 1

5 Replies - 5122 Views - Last Post: 26 February 2008 - 11:49 PM Rate Topic: -----

#1 adrianp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-February 08

vba excel error 1004

Post icon  Posted 25 February 2008 - 10:35 PM

Please help me to go on this error

It apears on last line of this piece of code, that is in a module, called from a checkbuton change eventhandler. called from
copy sentence called from
a module sub called from
a initialize userform eventhandler


Sub check_dependent_site_controls()
  Dim pControl As Control, pCell As Range, pList As Range
  Dim pStr1 As String, pstr2 As String

  For Each pControl In SiteForm.Controls
	 Set pList = Range("Parameters!Voip_Fields")
	 pStr1 = pControl.Name
	 
	 Set pCell = Worksheets("Parameters").Range("A$50:$A$59").Find(pStr1)



Is This A Good Question/Topic? 0
  • +

Replies To: vba excel error 1004

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: vba excel error 1004

Posted 25 February 2008 - 10:58 PM

Welcome to </dream.in.code> adrianp, glad you could make it! Hope to see you around the forums someday :)

For future reference you need to post your programming questions in the proper forum, . Don't worry about reposting it the proper forum, a Mod or Team Member will move it for you :)

I take it you didn't see the NO PROGRAMMING QUESTIONS heading at the top of this Forum?
Happy Coding!
Was This Post Helpful? 0
  • +
  • -

#3 adrianp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-February 08

Re: vba excel error 1004

Posted 25 February 2008 - 11:18 PM

Thanks for ypur reception Psycho, it was my mistake, as I'm really brain empty at this hour, 4 am, after all day trying to resolve the problem.

Please move my post to the correct forum,
and if you can give a help, I will be in debt for the rest of my life ;)
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: vba excel error 1004

Posted 26 February 2008 - 12:04 AM

I haven't been able to check this for errors, but try something like this:


Sub check_dependent_site_controls()
  Dim pControl As Control, pCell As Range, pList As Range
  Dim pStr1 As String, pstr2 As String
  Dim sheet As Worksheet
  Set sheet = Worksheets("Parameters")
  For Each pControl In SiteForm.Controls
     Set pList = Range("Parameters!Voip_Fields")
     pStr1 = pControl.Name
    
     Set pCell = sheets.Range("A$50:$A$59").Find(pStr1)




I am making the assumption that Parameters is a worksheet in your Excel file. For working with Excel in VBA it's usually a good idea to create a variable (of type Worksheet), then set it's value to your worksheet you wish to work with. In the code I offered I created a variable sheet of the type Worksheet, then I set its value to Worksheets("Parameters").

See if that helps any :)
Was This Post Helpful? 0
  • +
  • -

#5 adrianp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-February 08

Re: vba excel error 1004

Posted 26 February 2008 - 12:59 PM

I tried and had no success with it.
So I throwed all, and used control tags to clasify them as dependent on each checkbox and all is nice now.
I had to sacrifice easier parametrization using the cells range filled with control names.
The final solution follows,
Thanks psycho for your help atttempt.



Private Sub Chk_Voip_Change()
   If IsNull(Chk_Voip) Then Chk_Voip.Value = False
   
   check_dependent_site_controls "VoiceField", Chk_Voip.Value
End Sub

Sub check_dependent_site_controls(pStr As String, pBool As Boolean)
  Dim pCell As Range, pList As Range
  Dim pTag As String
  Dim Ws As Worksheet

  For Each pControl In SiteForm.Controls
     pTag = pControl.Tag
     ' pStr = "InternetField,DataField,VoiceField"
     If pStr = pTag Then
        pControl.Enabled = pBool
     End If
   Next pControl
End Sub


Was This Post Helpful? 0
  • +
  • -

#6 Realcoder  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 26-February 08

Re: vba excel error 1004

Posted 26 February 2008 - 11:49 PM

{Links Removed}

This post has been edited by PsychoCoder: 27 February 2008 - 12:53 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1