08-05-2010, 16:46
... to some list of commands and their meanings used in the programs VBA (Microsoft Office (Excel) macro tools) and BASIC, which i heard are pretty similar programming softwares. thank you very much
Sub fileloop()
Dim MyDir As String
Dim strPath As String
Dim strFileName As String
MyDir = ActiveWorkbook.Path ' current path
strPath = MyDir & "\files" ' files subdir
With Application.FileSearch
.NewSearch
.LookIn = strPath
.SearchSubFolders = False
.Filename = ".xls"
If .Execute > 0 Then
For Each strFileName In .FoundFiles
If InStr(1, strFileName, "ES") <> 0 Then
Workbooks.Open strFileName
With ActiveWorkbook
.Worksheets("Sheet1").Cells(1, 1).Value = "Hello"
.Save
.Close
End With
End If
Next
End If
End With
End Sub
Sub fileloop()
Application.DisplayAlerts = False
Dim MyDir As String
Dim strPath As String
Dim strFileName As Variant
Range("A1") = "vzorec"
Range("B1") = "CYC"
Range("C1") = "POS"
Range("E1") = "datum Å¡tetja"
Range("F1") = "SQP"
Range("G1") = "ID"
Range("N1") = "cpm"
Range("O1") = "cpm err"
Range("P1") = "cpm average"
Range("Q1") = "stdev cpm"
Range("R1") = "ratio"
Range("S1") = "datum Å¡tetja"
Range("T1") = "datum err."
Range("U1") = "average cpm"
Range("V1") = "stdev cpm"
Range("W1") = "datum Å¡tetja"
Range("X1") = "datum err"
MyDir = ActiveWorkbook.Path ' current path
strPath = "C:\Documents and Settings\Miha\My Documents\M&M\Kontrolne karte\Podatki\Izracun EXX\xls" ' files subdir
With Application.FileSearch
.NewSearch
.LookIn = strPath
.SearchSubFolders = False
.Filename = ".xls"
If .Execute > 0 Then
Dim a As Integer
a = 2
For Each strFileName In .FoundFiles
If InStr(1, strFileName, "IZRACUN") <> 0 Then
Workbooks.Open Filename:=strFileName, UpdateLinks:=3
Application.DisplayAlerts = False
aind$ = LTrim$(Str$(a))
With ActiveWorkbook
.Worksheets("LSC data-kontrolni").Select
Range("A2:X31").Select
Selection.Copy
Windows("kontrolna.xls").Activate
Worksheets("Sheet1").Select
Range("A" + aind$).Select
Selection.pastespecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
.Close
End With
a = a + 30
End If
Next
End If
End With
End Sub