Welcome to Dream.In.Code
Become a VB Expert!

Join 150,076 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,778 people online right now. Registration is fast and FREE... Join Now!




vba excel error 1004

 
Reply to this topicStart new topic

vba excel error 1004, it stops in a range.find sentence

adrianp
25 Feb, 2008 - 09:35 PM
Post #1

New D.I.C Head
*

Joined: 25 Feb, 2008
Posts: 4

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


CODE

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)

User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Vba Excel Error 1004
25 Feb, 2008 - 09:58 PM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Welcome to </dream.in.code> adrianp, glad you could make it! Hope to see you around the forums someday smile.gif

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 smile.gif

I take it you didn't see the NO PROGRAMMING QUESTIONS heading at the top of this Forum?
Happy Coding!
User is offlineProfile CardPM
+Quote Post

adrianp
RE: Vba Excel Error 1004
25 Feb, 2008 - 10:18 PM
Post #3

New D.I.C Head
*

Joined: 25 Feb, 2008
Posts: 4


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 wink2.gif



User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Vba Excel Error 1004
25 Feb, 2008 - 11:04 PM
Post #4

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

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


vb

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 smile.gif
User is offlineProfile CardPM
+Quote Post

adrianp
RE: Vba Excel Error 1004
26 Feb, 2008 - 11:59 AM
Post #5

New D.I.C Head
*

Joined: 25 Feb, 2008
Posts: 4

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.


vb


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



User is offlineProfile CardPM
+Quote Post

Realcoder
RE: Vba Excel Error 1004
26 Feb, 2008 - 10:49 PM
Post #6

New D.I.C Head
*

Joined: 26 Feb, 2008
Posts: 5


{Links Removed}

This post has been edited by PsychoCoder: 26 Feb, 2008 - 11:53 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 11:12PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month