The other function is the one that converts the data the machine gives into an excel format.
Here is that:
Function AnaOpen()
Dim AnzAnalog As Integer
Dim AnzMessungen As Integer
Dim Abtastrate As Integer
Dim FloatWert As Single
Dim Zeit As Long
Dim AnzWerte As Integer
Dim myRange As Range
setdir
AnalyseDatei = Application.GetOpenFilename("Analysis of Data Files (*.m*),*.m*,All (*.*),*.*", 10, "Import Data Analysis")
If AnalyseDatei = False Then
GoTo EndeAnaOpen
Else
Open AnalyseDatei For Binary Access Read As 200 '200 ist Filekennung
Worksheets("Sheet1").Activate
Cells.Select
Selection.ClearContents
Range("A1").Select
' Worksheets("Tabelle1").Clear
tstString = InputB(75, 200)
Get #200, , AnzMessungen
Get #200, , Abtastrate
tstString = InputB(4, 200)
'MsgBox Abtastrate
Get #200, , AnzAnalog
'MsgBox AnzAnalog
Cells(1, 1) = "Zeit"
Cells(2, 1) = "ms"
Rows(1).Font.FontStyle = "Fett"
Rows(2).Font.FontStyle = "Fett"
tstString = InputB(258, 200)
For i = 1 To AnzAnalog
Cells(1, i + 1) = Input(14, 200) '1.Kanalnamen einlesen
tstString = Input(12, 200) 'Bytes einlesen
Cells(2, i + 1) = Input(8, 200) 'Einheit ausgeben
tstString = Input(4, 200) 'Bytes einlesen
Next i
ReDim Werte(1 To AnzAnalog) As Single
AnzWerte = AnzAnalog + 1
ReDim WerteReihe(1 To AnzWerte) As Single
Application.ScreenUpdating = False
Cells(3, 1) = 0 ' Zeit Anfang
For i = 1 To AnzMessungen
Get #200, , Werte
For j = 1 To AnzAnalog
WerteReihe(j + 1) = Werte(j)
Next j
tstString = Input(8, 200) '2 Digitalworte
Get #200, , Zeit
WerteReihe(1) = Zeit
Set myRange = Range(Cells(i + 2, 1), Cells(i + 2, AnzWerte))
myRange.Rows = WerteReihe
Next i
Application.ScreenUpdating = True
End If
Close
EndeAnaOpen:
'Convert ms to seconds
Dim myLastRow As Long
' Find last row of data in column A
myLastRow = Cells(Rows.Count, "A").End(xlUp).Row
' Insert column B
Columns("B:B").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
' Insert formula in column B
Range("B3:B" & myLastRow).FormulaR1C1 = "=RC[-1]*0.001"
'Adds title Seconds
'
' TitleSeconds Macro
'
'
Range("B2").Select
ActiveCell.FormulaR1C1 = "s"
Range("B3").Select
End Function
So when this opens, I want it to auto start the code you helped me with. I placed a code for auto adding a column for something else I was doing but that didnt have a function or sub, it was just the code.
How could I go about doing this?