macro codes(help please)

shaskool33

New Member
Joined
Jul 21, 2011
Messages
7
this is my codes
I don`t know where is the problem
it says sub or function not defined
please help




Sub FindFeeder()

Dim i, m, n, z, Setting_var_dc As Integer
Dim path As String
Dim DIName, OCName, DIfeeder, OCfeeder, OCfeederN, OCNameN As String
Dim station, Datei As Object
Dim ControlOC, ControlDI, flag_reg As Boolean
Dim Line_Name(0 To 300) As String

' Initialisation
ControlOC = False
ControlDI = False
FeederFound = False
path_dc = "G:\Azarbayjan"


If Different_Node = False Then
path = path_dc & "\" & RegionName

' Create FileSystemObject
Set fs = CreateObject("Scripting.FileSystemObject")

' Find active protection devices in the chosen region
Set f1 = fs.GetFolder(path + "\Protection")
Set f2 = f1.subfolders
End If

If Different_Node = True Then
GoTo jump
End If

For Each station In f2

jump:
' Open each prot-file in folder
If Different_Node Then
Set g2 = station2.Files
Else
Set g2 = station.Files
End If

For Each Datei In g2
If Different_Node Then
stationname = station2.Name
Else
stationname = station.Name
End If

flagDI = False
flagOC_both = False
flagOC = False
flagOCN = False
DIfeeder = ""
OCfeeder = ""
OCfeederN = ""
For z = 1 To 1
' If prot-file and voltage level >= 230kV then open it
If UCase(Left(Datei.Name, 4)) = "PROT" And Mid(Datei.Name, 6, 1) > 7 Then

wbook = Datei.Name
pathwbook = Datei.ParentFolder.path

Setting_var_dc = 0


If UCase(Left(Datei.Name, 4)) = "PROT" And Mid(Datei.Name, 6, 1) > 7 Then
Setting_var_dc = 0
wbook = Datei.Name
pathwbook = Datei.ParentFolder.path
End If
If getValue(pathwbook, wbook, "21_21N", 11, 4) <> "" And getValue(pathwbook, wbook, "21_21N", 11, 6) = "" Then
pathwbook.wbook("21_21N", 11, 6) = pathwbook.wbook("21_21N", 11, 4)
End If
End If
Next
Next
Next
End Sub
 
Last edited:
here is the complete code

Sub FindFeeder()
Dim MyFile As String
Dim i, m, n, z, Setting_var_dc As Integer
Dim path As String
Dim DIName, OCName, DIfeeder, OCfeeder, OCfeederN, OCNameN As String
Dim station, Datei As Object
Dim ControlOC, ControlDI, flag_reg As Boolean
Dim Line_Name(0 To 300) As String

' Initialisation
ControlOC = False
ControlDI = False
FeederFound = False
path_dc = "G:\Azarbayjan"


If Different_Node = False Then
path = path_dc & "\" & RegionName

' Create FileSystemObject
Set fs = CreateObject("Scripting.FileSystemObject")

' Find active protection devices in the chosen region
Set f1 = fs.GetFolder(path + "\Protection")
Set f2 = f1.subfolders
End If

If Different_Node = True Then
GoTo jump
End If

For Each station In f2

jump:
' Open each prot-file in folder
If Different_Node Then
Set g2 = station2.Files
Else
Set g2 = station.Files
End If

For Each Datei In g2
If Different_Node Then
stationname = station2.Name
Else
stationname = station.Name
End If

flagDI = False
flagOC_both = False
flagOC = False
flagOCN = False
DIfeeder = ""
OCfeeder = ""
OCfeederN = ""
For z = 1 To 1
' If prot-file and voltage level >= 230kV then open it
If UCase(Left(Datei.Name, 4)) = "PROT" And Mid(Datei.Name, 6, 1) > 7 Then

wbook = Datei.Name
pathwbook = Datei.ParentFolder.path
Setting_var_dc = 0


MyFile = wbook
Do While MyFile <> ""
Open wbook For Random As FreeFile
Sheets("21_21N").Select
If Cells(11, 4) <> "" And Cells(11, 6) = "" Then 'Change to what you need it to do
Cells(11, 6) = Tabelle6.Cells(11, 4)
ActiveWorkbook.Close True
MyFile = Dir
End If
Loop
End If
Next
Next
Next
End Sub



yes I steped through the code and the fault is here:
Sheets("21_21N").Select

here is one of the files that should be opened:
http://www.4shared.com/document/b3pP22iJ/Prot_8AQHFP22.html
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top