Re: Makros und Tastenkombinationen
06.11.2002 15:21:09
OLL!
Hello again .. ;-)Nun gut, hier ist der Code:
Makro 1 (Daten einlesen):
Sub Daten_importieren()
Workbooks.OpenText FileName:= _
"C:\Programme\...\.txt", Origin:= _xlWindows, StartRow:=1,DataType:=xlDelimited, TextQualifier:= _xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, Semicolon:=False, _Comma:=False, Space:=True,Other:=False,FieldInfo:=Array (Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1),
Array(6, 1), Array(7, 1), Array(8, 1), _Array(9, 1),
Array(10, 1), Array(11, 1), Array(12, 1), Array(13,1),Array(14,1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1), Array(27, 1), Array(28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array(33, 1), Array(34, 1), Array(35, 1), Array(36, 1), Array(37, 1), Array(38, 1), Array(39, 1), Array(40, 1), Array(41, 1), Array(42, 1), Array(43, 1), Array(44, 1))
End Sub
Sodann auch gleich Makro 2:
Sub Messdaten_formatieren()
Rows("1:1").Select
Selection.Insert Shift:=xlDown
Rows("2:2").Select
Selection.Insert Shift:=xlDown
Range("A1").Select
ActiveCell.FormulaR1C1 = "SNR"
Range("B1").Select
ActiveCell.FormulaR1C1 = "Resulat der"
Range("B2").Select
ActiveCell.FormulaR1C1 = "Kalibrierung"
Range("B1").Select
ActiveCell.FormulaR1C1 = "Resultat der"
Columns("B:B").Select
Range("C1").Select
ActiveCell.FormulaR1C1 = "Uhrzeit"
Range("D1").Select
ActiveCell.FormulaR1C1 = "Datum"
Range("F1").Select
ActiveCell.FormulaR1C1 = "Temperatur (Raum)"
Range("F2").Select
ActiveCell.FormulaR1C1 = "[ °C ]"
Columns("F:F").Select
Selection.Columns.AutoFit
Columns("B:B").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
.MergeCells = False
End With
Selection.Rows.AutoFit
Range("H1:K1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
.MergeCells = True
End With
ActiveCell.FormulaR1C1 = "Heizleistungen, Adapter A"
Range("I2:J2").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
.MergeCells = True
End With
ActiveCell.FormulaR1C1 = "[ mW ]"
Range("M2").Select
ActiveCell.FormulaR1C1 = "[ mW ]"
Range("K2").Select
Range("L2").Select
Range("M2").Select
Range("L1:N1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
.MergeCells = True
End With
ActiveCell.FormulaR1C1 = "T_Kalibrwiderstände, Adapter A"
Range("M2").Select
ActiveCell.FormulaR1C1 = "[ Ohm ]"
Range("P1:S1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
.MergeCells = True
End With
ActiveCell.FormulaR1C1 = "Heizleistungen, Adapter B"
Range("Q2:R2").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
.MergeCells = True
End With
ActiveCell.FormulaR1C1 = "[ mW ]"
Range("T1:V1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
.MergeCells = True
End With
ActiveCell.FormulaR1C1 = "T_Kalibrwiderstände, Adapter B"
Range("U2").Select
ActiveCell.FormulaR1C1 = "[ °C ]"
Range("M2").Select
ActiveCell.FormulaR1C1 = "[ °C ]"
Range("M2").Select
ActiveCell.FormulaR1C1 = "[ °C ]"
Range("X1:Y1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
.MergeCells = True
End With
ActiveCell.FormulaR1C1 = "Wdhsmessung, Adapter A"
Range("X2").Select
ActiveCell.FormulaR1C1 = "Pin 5 [ VDC ]"
Range("Y2").Select
ActiveCell.FormulaR1C1 = "Pin 6 [ VDC ]"
Range("AA1:AB1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
.MergeCells = True
End With
ActiveCell.FormulaR1C1 = "Wdhsmessung, Adapter B"
Range("AA2").Select
ActiveCell.FormulaR1C1 = "Pin 5 [ VDC ]"
Range("AB2").Select
ActiveCell.FormulaR1C1 = "Pin 6 [ VDC ]"
Range("AD1:AF1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
.MergeCells = True
End With
ActiveCell.FormulaR1C1 = "RPT-Widerstände, Adapter A"
Range("AE2").Select
ActiveCell.FormulaR1C1 = "[ Ohm ]"
Range("AH1:AJ1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
.MergeCells = True
End With
ActiveCell.FormulaR1C1 = "RPT-Widerstände, Adapter B"
Range("AI2").Select
ActiveCell.FormulaR1C1 = "[ Ohm ]"
Range("AL1:AN1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
.MergeCells = True
End With
ActiveCell.FormulaR1C1 = "RVP-Widerstände, Adapter A"
Range("AM2").Select
ActiveCell.FormulaR1C1 = "[ Ohm ]"
Range("AP1:AR1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
.MergeCells = True
End With
ActiveCell.FormulaR1C1 = "RVP-Widerstände, Adapter B"
Range("AQ2").Select
ActiveCell.FormulaR1C1 = "[ Ohm ]"
Range("H1:K1,H:H").Select
ActiveWindow.ScrollColumn = 14
Range("X:Y,Y:Y").Select
Selection.Columns.AutoFit
Columns("AA:AB").Select
Selection.Columns.AutoFit
Columns("A:AR").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
End With
Columns("E:E").Select
Selection.Delete Shift:=xlToLeft
Columns("F:F").Select
Selection.Delete Shift:=xlToLeft
Columns("M:M").Select
Selection.Delete Shift:=xlToLeft
Columns("T:T").Select
Selection.Delete Shift:=xlToLeft
Columns("V:V").Select
Selection.Delete Shift:=xlToLeft
Columns("X:X").Select
Selection.Delete Shift:=xlToLeft
Columns("AA:AA").Select
Selection.Delete Shift:=xlToLeft
Columns("AD:AD").Select
Selection.Delete Shift:=xlToLeft
Columns("AG:AG").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select
End Sub
Wenn man nun das " End Sub " von Makro 1 und von Makro 2 " Sub... " wegläßt, werden nur die Daten eingelesen.
O L L !