keates6103
New Member
- Joined
- Nov 19, 2015
- Messages
- 1
I have this code, it works brilliantly with one workbook, but if I add it to my ribbon button it doesn't work on other workbooks?
My experience of Excel is very limited and this code has been cobbled together over a number of weeks, is there something really obvious I am doing wrong?
My aim is to disseminate this among my colleagues as an install-able ribbon item to make our reading of raw data easier and faster.
Any help or guidance would be most appreciated, I am expecting laughs at my inexperienced use of vba!
Sub CreateSheetsFromAList()
'Sub to create all required worksheets:
Application.ScreenUpdating = False
'Stopping Application Alerts (because pop-up asks if you really want to delete the sheet)
Application.DisplayAlerts = False
'Remove Errors if sheets dont exist
On Error Resume Next
'Rename current Sheet for formula to reference:
Sheets("Sheet1").Select
ActiveSheet.Name = "RawData"
'Tablerise the raw data for referencing
''Dim Rng1 As Range
'''Change the range of cells (A1:B15) to be the range of cells you want to define
''Set Rng1 = Sheets("Sheet1").Range("A1:B15")
''ActiveWorkbook.Names.Add Name:="MyRange", RefersTo:=Rng1
'need to chnge this to 'last cell with data' rather than HU9999
'ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$7:$HU$9999"), , xlYes).Name = "Table3"
Dim LastRowRaw As Long
LastRowRaw = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$7:$IW" & LastRowRaw), , xlYes).Name = "Table3"
ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleLight2"
'delete the default sheets
Sheets("Sheet2").Delete
Sheets("Sheet3").Delete
'Magnet
Set wsSheet = Sheets("Magnet")
If wsSheet Is Nothing Then 'Checks to see if sheet already exists or not.
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "Magnet" 'renames the new worksheet
Else
Sheets("magnet").Delete 'clears old sheet
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "Magnet" 'renames the new worksheet
End If
'Fuel
Set wsSheet = Sheets("Fuel")
If wsSheet Is Nothing Then 'Checks to see if sheet already exists or not.
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "Fuel" 'renames the new worksheet
Else
Sheets("Fuel").Delete 'clears old sheet
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "Fuel" 'renames the new worksheet
End If
'24V Supplies
Set wsSheet = Sheets("24V Supplies")
If wsSheet Is Nothing Then 'Checks to see if sheet already exists or not.
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "24V Supplies" 'renames the new worksheet
Else
Sheets("24V Supplies").Delete 'clears old sheet
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "24V Supplies" 'renames the new worksheet
End If
'Engine Air Filter
Set wsSheet = Sheets("Engine Air Filter")
If wsSheet Is Nothing Then 'Checks to see if sheet already exists or not.
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "Engine Air Filter" 'renames the new worksheet
Else
Sheets("Engine Air Filter").Delete 'clears old sheet
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "Engine Air Filter" 'renames the new worksheet
End If
'Electronics Temperatures
Set wsSheet = Sheets("ElectronicTemp")
If wsSheet Is Nothing Then 'Checks to see if sheet already exists or not.
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "ElectronicTemp" 'renames the new worksheet
Else
Sheets("ElectronicTemp").Delete 'clears old sheet
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "ElectronicTemp" 'renames the new worksheet
End If
Call Magnet_ready
Call Fuel_ready
Call Diff_Press
Call LowV_Ready
Call Temperatures_ready
'Turn application errors back on:
'Enabling Application alerts once we are done with our task
Application.DisplayAlerts = True
Application.ScreenUpdating = True
On Error GoTo 0
End Sub
Sub Magnet_ready()
'
' Magnet_ready Macro
' Creates magnet sheet table and includes flux calculation formula
'
'
Sheets("RawData").Select 'Selects main data records sheet
Range("Table3[[#All],[Control Time ]]").Select 'Selects the entire 'Control Time' Column
Selection.Copy 'Copies it
Sheets("Magnet").Select 'Selects the 'Magnet' Sheet
Range("B7").Select 'Selects B7 (the location where I want this pasted from (row number is important to match the data record sheet)
ActiveSheet.Paste 'Pastes the 'control time'column
Sheets("RawData").Select 'Back to main data records sheet
Range("Table3[[#All],[Gen Speed (rpm)]]").Select 'Selects the entire 'Gen Speed' Column
Application.CutCopyMode = False 'Clears the Clipboard (this stops the 'large amount of information' error
Selection.Copy 'Copies the Gen Speed Column
Sheets("Magnet").Select 'Goes back to the Magnet sheet
Range("C7").Select 'Selects cell C7 (where I want the data pasted)
ActiveSheet.Paste 'Pastes the data
Sheets("RawData").Select 'Back to main recording
Range("Table3[[#All],[Gen Quadrature Voltage (V)]]").Select 'Selects the entire Gen Quadrature Voltage Column
Application.CutCopyMode = False 'Clears the clipboard
Selection.Copy 'Copies the Gen Quadrature Voltage
Sheets("Magnet").Select 'Selects Magnet sheet
Range("D7").Select
ActiveSheet.Paste 'Pastes the data
Range("B7").Select 'Selects cell B7 (the start of my in-a-minute table) (since added to the listobjects below)
Dim LR As Long
LR = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$B$7:$D" & LR), , xlYes).Name = "Table6"
Range("E7").FormulaR1C1 = "Magnetization (wb)"
Range("E8").FormulaR1C1 = _
"=IF(Table6[@[Gen Speed (rpm)]=]=>10000,(IFERROR((Table6[@[Gen Quadrature Voltage (V)]])/(2*PI()*Table6[@[Gen Speed (rpm)]]/60),"""")),"""")"
'for this formula to work I had to go tools>references and add Microsoft Forms 2.0 Object Library
'Little magnet summary at the top
Range("F2").Formula = "Average Magnetization"
Range("G2").Formula = "Pass or Fail"
Range("H2").Formula = "C200 legacy Flux"
Range("H3").Formula = "0.056"
Range("F3").Formula = "=IFERROR(AVERAGEIF(Table6[Magnetization (wb)],""<>0""), ""No data entered"")"
Range("G3").Formula = "=IF(($F$3=""No data entered""),""N/A"",(IF(($F$3)>($H$3),""PASS"", ""FAIL"")))"
Dim LS As Long
LS = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$F$2:$H$3"), , xlYes).Name = "Table7"
End Sub
Sub Fuel_ready()
'Dim Time As Range
'Set Time = Sheets("Data Recording").Range("Table3[[#All],[Control Time ]]")
' Pasting initial Info Columns:
Sheets("RawData").Select 'Selects main data records sheet
Range("Table3[[#All],[Control Time ]]").Select 'Selects the entire 'Control Time' Column
Selection.Copy 'Copies it
Sheets("Fuel").Select 'Selects the 'Fuel' Sheet
Range("B7").Select 'Selects B7 (the location where I want this pasted from (row number is important to match the data record sheet)
ActiveSheet.Paste 'Pastes the 'control time' column
'Range("B7").Copy Sheets("Data Recording").Range("Table[[#All],[Control Time]]") 'doesnt work
'Worksheets("Fuel 2").Range("B7").Value = Worksheets("Data recording").Range("Table[[#All],[Control Time]]").Value 'doesnt work
'wb.Sheets("Data Recording").Range("Table3[[#All],[Control Time]]").Copy
'Selection.Copy
'wb.Sheets("Fuel 2").Range("B7").Paste
Sheets("RawData").Select 'Selects main data records sheet
Range("Table3[[#All],[System State ]]").Select 'Selects the entire 'System State' Column
Application.CutCopyMode = False 'Clears the Clipboard (this stops the 'large amount of information' error
Selection.Copy 'Copies it
Sheets("Fuel").Select 'Selects the 'Fuel' Sheet
Range("C7").Select 'Selects C7 (the location where I want this pasted to (row number is important to match the data record sheet)
ActiveSheet.Paste 'Pastes the 'System State'column
Sheets("RawData").Select 'Selects main data records sheet
Range("Table3[[#All],[Fuel Inlet Pres (kPa)]]").Select 'Selects the entire 'Fuel Inlet Pressure' Column
Application.CutCopyMode = False 'Clears the Clipboard (this stops the 'large amount of information' error
Selection.Copy 'Copies it
Sheets("Fuel").Select 'Selects the 'Fuel' Sheet
Range("F7").Select 'Selects D7 (the location where I want this pasted from (row number is important to match the data record sheet)
ActiveSheet.Paste 'Pastes the 'Fuel Pressure'column
Sheets("RawData").Select 'Back to main data records sheet
Range("Table3[[#All],[Turbine Exit Temp (°C)]]").Select 'Selects the entire 'TET Average' Column
Application.CutCopyMode = False 'Clears the Clipboard (this stops the 'large amount of information' error
Selection.Copy 'Copies the Gen Speed Column
Sheets("Fuel").Select 'Goes back to the Magnet sheet
Range("H7").Select 'Selects cell C7 (where I want the data pasted)
ActiveSheet.Paste 'Pastes the data
Sheets("RawData").Select 'Back to main recording
Range("Table3[[#All],[FCB Solenoid Command ]]").Select 'Selects the entire Gen Quadrature Voltage Column
Application.CutCopyMode = False 'Clears the clipboard
Selection.Copy 'Copies the Gen Quadrature Voltage
Sheets("Fuel").Select 'Selects Magnet sheet
Range("J7").Select 'Selects cell D7 (where I want to paste)
ActiveSheet.Paste 'Pastes the data
Range("B7").Select 'Selects cell B7 (the start of my in-a-minute table) (since added to the listobjects below)
' Now fill in the Heading gaps: 'For filling manual ranges
Range("D7").FormulaR1C1 = "Engine STATE Hex" 'Heading here, need to add the formula once table is formed below
Range("E7").FormulaR1C1 = "STATE" 'Column head for Plain English State (Using LOOKUP table)
Range("G7").FormulaR1C1 = "Pressure OK?" 'Too High/Too Low/Good Pressure
Range("I7").FormulaR1C1 = "TET OK?" 'Too High/Too Low/Good TET
Range("K7").FormulaR1C1 = "Remove 0x" 'Column with removed 0x prefix from solenoid command
Range("L7").FormulaR1C1 = "Binary Version" 'Inserts column to Convert the Hex from the solenoid command into a single binary word for conversion
Range("M7").FormulaR1C1 = "(bit15)"
Range("N7").FormulaR1C1 = "(bit14)"
Range("O7").FormulaR1C1 = "Compressor (bit13)"
Range("P7").FormulaR1C1 = "(bit12)"
Range("Q7").FormulaR1C1 = "(bit11)"
Range("R7").FormulaR1C1 = "MainFan (bit10)"
Range("S7").FormulaR1C1 = "(bit9)"
Range("T7").FormulaR1C1 = "Igniter (bit8)"
Range("U7").FormulaR1C1 = "ShutOffVv1 (bit7)"
Range("V7").FormulaR1C1 = "Inj 6 (bit6)"
Range("W7").FormulaR1C1 = "Inj 5 (bit5)"
Range("X7").FormulaR1C1 = "Inj 4 (bit4)"
Range("Y7").FormulaR1C1 = "Inj 3 (bit3)"
Range("Z7").FormulaR1C1 = "Inj 2 (bit2)"
Range("AA7").FormulaR1C1 = "Inj 1 (bit1)"
Range("AB7").FormulaR1C1 = "ShutOffVv2 (bit0)" 'Inserts all the bit columns (the unused ones I will probably need code to hide afterwards)
'Create the table:
Dim LR As Long
LR = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$B$7:$AB" & LR), , xlYes).Name = "Table8"
'Create the reference tables
'need column AE to be Test:
Range("AE1:AE32").NumberFormat = "@"
'table 19 is the state translator
Range("AE4").Formula = "State"
Range("AF4").Formula = "Plain English"
Range("AE5").Formula = "00"
Range("AE6").Formula = "01"
Range("AE7").Formula = "02"
Range("AE8").Formula = "03"
Range("AE9").Formula = "04"
Range("AE10").Formula = "05"
Range("AE11").Formula = "06"
Range("AE12").Formula = "07"
Range("AE13").Formula = "08"
Range("AE14").Formula = "09"
Range("AE15").Formula = "0A"
Range("AE16").Formula = "0B"
Range("AE17").Formula = "0C"
Range("AE18").Formula = "0D"
Range("AE19").Formula = "0E"
Range("AE20").Formula = "0F"
Range("AE21").Formula = "10"
Range("AE22").Formula = "11"
Range("AF5").Formula = "Not Connected"
Range("AF6").Formula = "Standby"
Range("AF7").Formula = "Prepare to Start"
Range("AF8").Formula = "Lift-Off"
Range("AF9").Formula = "Prepare to Light"
Range("AF10").Formula = "Acceleration"
Range("AF11").Formula = "Run"
Range("AF12").Formula = "Load"
Range("AF13").Formula = "ReCharge"
Range("AF14").Formula = "Cooldown"
Range("AF15").Formula = "Warmdown"
Range("AF16").Formula = "Restart"
Range("AF17").Formula = "Shutdown"
Range("AF18").Formula = "Fault"
Range("AF19").Formula = "Disable"
Range("AF20").Formula = "Bad Config"
Range("AF21").Formula = "Download"
Range("AF22").Formula = "Idle Recharge"
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$AE$4:$AF$22"), , xlYes).Name = "Table19"
'Table 26 is the max/min kpa
Range("AE24").Formula = "Max/Min"
Range("AE25").Formula = "Fuel Pressure Min"
Range("AE26").Formula = "Fuel Pressure Max"
Range("AF24").Formula = "kpa"
Range("AF25").Formula = "517"
Range("AF26").Formula = "552"
Range("AG24").Formula = "OK"
Range("AG25").Formula = "Too Low"
Range("AG26").Formula = "Too High"
Range("AH24").Formula = "Psi"
Range("AH25").Formula = "75"
Range("AH26").Formula = "80"
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$AE$24:$AH$26"), , xlYes).Name = "Table26"
'Table 27 is the max/min temp
Range("AE28").Formula = "Max/Min"
Range("AE29").Formula = "TET Average Min"
Range("AE30").Formula = "TET Average Max"
'this 07 wont work unless i format the cell to text first
Range("AE31").Formula = "07"
Range("AF28").Formula = "degC"
Range("AF29").Formula = "629"
Range("AF30").Formula = "641"
Range("AF31").Formula = ""
Range("AG28").Formula = "OK"
Range("AG29").Formula = "Too Low"
Range("AG30").Formula = "Too High"
Range("AG31").Formula = "Not in Load"
Range("AH28").Formula = "degF"
Range("AH29").Formula = "1165"
Range("AH30").Formula = "1185"
Range("AH31").Formula = ""
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$AE$28:$AH$31"), , xlYes).Name = "Table27"
'Fill the bespoke page formula into the table (by inserting the formula in the top cell of each column):
Range("D8").FormulaR1C1 = _
"=RIGHT([@[System State ]],2)"
'Creates formula to read turbine state, just last two digits of mode/state hex
Range("E8").FormulaR1C1 = _
"=VLOOKUP([@[Engine STATE Hex]],Table19,2,FALSE)"
'Creates formula to write plain english states from the lookup table (Table 19)
Range("G8").Formula = _
"=IF(([@[Fuel Inlet Pres (kPa)]=]=>$AF$25),(IF(([@[Fuel Inlet Pres (kPa)]=]=>$AF$26),$AG$26,$AG$24)),$AG$25)"
'Creates formula to write plain english indication of fuel from AB25 and 26
Range("I8").Formula = _
"=IF(([@[STATE]]=""LOAD""),(IF(([@[Turbine Exit Temp (°C)]=]=>$AF$29),(IF(([@[Turbine Exit Temp (°C)]=]=>$AF$30),$AG$30, Table27[[#Headers],[OK]])),$AG$29)),$AG$31)"
'Creates formula to write plain english indication of TET from AB25 and 26
Range("K8").Formula = _
"=RIGHT([@[FCB Solenoid Command ]],4)"
'Creates formula to remove 0x prefix
Range("L8").Formula = _
"=CONCATENATE(HEX2BIN(LEFT([@[Remove 0x]],2),8),HEX2BIN(RIGHT(RIGHT([@[Remove 0x]],4),2),8))"
'Writes full 16bit binary version of sol. command
Range("M8").Formula = "=MID([@[Binary Version]],COLUMNS($K3:K3),1)"
Range("N8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:E1),1)"
Range("O8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:F1),1)"
Range("P8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:G1),1)"
Range("Q8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:H1),1)"
Range("R8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:I1),1)"
Range("S8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:J1),1)"
Range("T8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:K1),1)"
Range("U8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:L1),1)"
Range("V8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:M1),1)"
Range("W8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:N1),1)"
Range("X8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:O1),1)"
Range("Y8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:P1),1)"
Range("Z8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:Q1),1)"
Range("AA8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:R1),1)"
Range("AB8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:S1),1)"
'Split up binary into individual bits
'Hide Columns:
Columns(3).Resize(, 2).Select
Selection.EntireColumn.Hidden = True
'Hides the System state with 0x prefix column and the State hex
Columns(10).Resize(, 3).Select
Selection.EntireColumn.Hidden = True
'Hides sol command, Hex with 0x removed column and binary equivalent column
Range("B7").Select
End Sub
Sub Diff_Press()
Sheets("RawData").Select 'Selects main data records sheet
Range("Table3[[#All],[Diff Air Pressure (kPa)]]").Select 'Selects the entire 'Control Time' Column
Selection.Copy 'Copies it
Sheets("Engine Air Filter").Select 'Selects the 'Engine Air Filter' Sheet
Range("B7").Select 'Selects B7 (the location where I want this pasted from (row number is important to match the data record sheet)
ActiveSheet.Paste 'Pastes the 'Differential Air Pressure'column
Dim LR As Long
LR = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$B$7:$B" & LR), , xlYes).Name = "Table9"
Range("F2").Formula = "Average Differential Pressure"
Range("G2").Formula = "Pass or Fail"
Range("H2").Formula = "Maximum Diff."
Range("H3").Formula = "2"
Range("F3").Formula = "=IFERROR(AVERAGEIF(Table9[Diff Air Pressure (kPa)],""<>0""), ""No Data Entered/Recorded"")"
Range("G3").Formula = "=IF(($F$3=""No data entered""),""N/A"",(IF(($F$3)<($H$3),""PASS"", ""FAIL"")))"
Dim LS As Long
LS = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$F$2:$H$3"), , xlYes).Name = "Table10"
End Sub
Sub LowV_Ready()
Sheets("RawData").Select
Range("Table3[[#All],[Power Supply Voltage (V)]]").Select
Selection.Copy
Sheets("24V Supplies").Select
Range("B7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[FCM Switch Power (Vdc)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("24V Supplies").Select
Range("C7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[FCM Pwr Supply (Vdc)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("24V Supplies").Select
Range("D7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[FCM 5.0 V (Vdc)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("24V Supplies").Select
Range("E7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[FCM 2.5 VREF (Vdc)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("24V Supplies").Select
Range("F7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[FCB Control Power Supply (V)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("24V Supplies").Select
Range("G7").Select
ActiveSheet.Paste
Range("B7").Select
Sheets("RawData").Select
Range("Table3[[#All],[FCB Switched Power Supply (V)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("24V Supplies").Select
Range("H7").Select
ActiveSheet.Paste
Range("B7").Select
Sheets("RawData").Select
Range("Table3[[#All],[FCB 5V Analog Power (V)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("24V Supplies").Select
Range("I7").Select
ActiveSheet.Paste
Range("B7").Select
Sheets("RawData").Select
Range("Table3[[#All],[FCB 2.5V ADC Ref (V)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("24V Supplies").Select
Range("J7").Select
ActiveSheet.Paste
Range("B7").Select
Dim LR As Long
LR = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$B$7:$J" & LR), , xlYes).Name = "Table11"
End Sub
Sub Temperatures_ready()
'
' Electronic Temperatures_ready Macro
'
Sheets("RawData").Select
Range("Table3[[#All],[Main Board Temp (°C)]]").Select
Selection.Copy
Sheets("ElectronicTemp").Select
Range("B7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Bat Therm.Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("C7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Bat PM Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("D7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[BC Heatsink T (°C)]]").Select
Selection.Copy
Sheets("ElectronicTemp").Select
Range("E7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[BC Board T (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("F7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Inv Heat Sink Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("G7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Brake Temp (°C)]]").Select
Selection.Copy
Sheets("ElectronicTemp").Select
Range("H7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[CHP Board Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("I7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[FCM Board Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("J7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[FCM Cold Junc T (°C)]]").Select
Selection.Copy
Sheets("ElectronicTemp").Select
Range("K7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Gen IGBT A Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("L7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Gen IGBT B Ttemp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("M7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Gen IGBT C Temp (°C)]]").Select
Selection.Copy
Sheets("ElectronicTemp").Select
Range("N7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Gen IGBT Brake Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("O7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Gen ICB Board Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("P7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Gen PDM1 Board Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("Q7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Gen PDM2 Board Temp (°C)]]").Select
Selection.Copy
Sheets("ElectronicTemp").Select
Range("R7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Inv IGBT A Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("S7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Inv IGBT B Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("T7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Inv IGBT C Temp (°C)]]").Select
Selection.Copy
Sheets("ElectronicTemp").Select
Range("U7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Inv IGBT N Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("V7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Inv ICB Board Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("W7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Sec Bat Therm.Temp (°C)]]").Select
Selection.Copy
Sheets("ElectronicTemp").Select
Range("X7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Sec Bat PM Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("Y7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Sec BC Heatsink T (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("Z7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Sec BC Board T (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("AA7").Select
ActiveSheet.Paste
Range("B7").Select
Dim LR As Long
LR = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$B$7:$AA" & LR), , xlYes).Name = "Table12"
End Sub
My experience of Excel is very limited and this code has been cobbled together over a number of weeks, is there something really obvious I am doing wrong?
My aim is to disseminate this among my colleagues as an install-able ribbon item to make our reading of raw data easier and faster.
Any help or guidance would be most appreciated, I am expecting laughs at my inexperienced use of vba!
Sub CreateSheetsFromAList()
'Sub to create all required worksheets:
Application.ScreenUpdating = False
'Stopping Application Alerts (because pop-up asks if you really want to delete the sheet)
Application.DisplayAlerts = False
'Remove Errors if sheets dont exist
On Error Resume Next
'Rename current Sheet for formula to reference:
Sheets("Sheet1").Select
ActiveSheet.Name = "RawData"
'Tablerise the raw data for referencing
''Dim Rng1 As Range
'''Change the range of cells (A1:B15) to be the range of cells you want to define
''Set Rng1 = Sheets("Sheet1").Range("A1:B15")
''ActiveWorkbook.Names.Add Name:="MyRange", RefersTo:=Rng1
'need to chnge this to 'last cell with data' rather than HU9999
'ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$7:$HU$9999"), , xlYes).Name = "Table3"
Dim LastRowRaw As Long
LastRowRaw = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$7:$IW" & LastRowRaw), , xlYes).Name = "Table3"
ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleLight2"
'delete the default sheets
Sheets("Sheet2").Delete
Sheets("Sheet3").Delete
'Magnet
Set wsSheet = Sheets("Magnet")
If wsSheet Is Nothing Then 'Checks to see if sheet already exists or not.
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "Magnet" 'renames the new worksheet
Else
Sheets("magnet").Delete 'clears old sheet
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "Magnet" 'renames the new worksheet
End If
'Fuel
Set wsSheet = Sheets("Fuel")
If wsSheet Is Nothing Then 'Checks to see if sheet already exists or not.
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "Fuel" 'renames the new worksheet
Else
Sheets("Fuel").Delete 'clears old sheet
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "Fuel" 'renames the new worksheet
End If
'24V Supplies
Set wsSheet = Sheets("24V Supplies")
If wsSheet Is Nothing Then 'Checks to see if sheet already exists or not.
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "24V Supplies" 'renames the new worksheet
Else
Sheets("24V Supplies").Delete 'clears old sheet
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "24V Supplies" 'renames the new worksheet
End If
'Engine Air Filter
Set wsSheet = Sheets("Engine Air Filter")
If wsSheet Is Nothing Then 'Checks to see if sheet already exists or not.
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "Engine Air Filter" 'renames the new worksheet
Else
Sheets("Engine Air Filter").Delete 'clears old sheet
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "Engine Air Filter" 'renames the new worksheet
End If
'Electronics Temperatures
Set wsSheet = Sheets("ElectronicTemp")
If wsSheet Is Nothing Then 'Checks to see if sheet already exists or not.
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "ElectronicTemp" 'renames the new worksheet
Else
Sheets("ElectronicTemp").Delete 'clears old sheet
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = "ElectronicTemp" 'renames the new worksheet
End If
Call Magnet_ready
Call Fuel_ready
Call Diff_Press
Call LowV_Ready
Call Temperatures_ready
'Turn application errors back on:
'Enabling Application alerts once we are done with our task
Application.DisplayAlerts = True
Application.ScreenUpdating = True
On Error GoTo 0
End Sub
Sub Magnet_ready()
'
' Magnet_ready Macro
' Creates magnet sheet table and includes flux calculation formula
'
'
Sheets("RawData").Select 'Selects main data records sheet
Range("Table3[[#All],[Control Time ]]").Select 'Selects the entire 'Control Time' Column
Selection.Copy 'Copies it
Sheets("Magnet").Select 'Selects the 'Magnet' Sheet
Range("B7").Select 'Selects B7 (the location where I want this pasted from (row number is important to match the data record sheet)
ActiveSheet.Paste 'Pastes the 'control time'column
Sheets("RawData").Select 'Back to main data records sheet
Range("Table3[[#All],[Gen Speed (rpm)]]").Select 'Selects the entire 'Gen Speed' Column
Application.CutCopyMode = False 'Clears the Clipboard (this stops the 'large amount of information' error
Selection.Copy 'Copies the Gen Speed Column
Sheets("Magnet").Select 'Goes back to the Magnet sheet
Range("C7").Select 'Selects cell C7 (where I want the data pasted)
ActiveSheet.Paste 'Pastes the data
Sheets("RawData").Select 'Back to main recording
Range("Table3[[#All],[Gen Quadrature Voltage (V)]]").Select 'Selects the entire Gen Quadrature Voltage Column
Application.CutCopyMode = False 'Clears the clipboard
Selection.Copy 'Copies the Gen Quadrature Voltage
Sheets("Magnet").Select 'Selects Magnet sheet
Range("D7").Select
ActiveSheet.Paste 'Pastes the data
Range("B7").Select 'Selects cell B7 (the start of my in-a-minute table) (since added to the listobjects below)
Dim LR As Long
LR = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$B$7:$D" & LR), , xlYes).Name = "Table6"
Range("E7").FormulaR1C1 = "Magnetization (wb)"
Range("E8").FormulaR1C1 = _
"=IF(Table6[@[Gen Speed (rpm)]=]=>10000,(IFERROR((Table6[@[Gen Quadrature Voltage (V)]])/(2*PI()*Table6[@[Gen Speed (rpm)]]/60),"""")),"""")"
'for this formula to work I had to go tools>references and add Microsoft Forms 2.0 Object Library
'Little magnet summary at the top
Range("F2").Formula = "Average Magnetization"
Range("G2").Formula = "Pass or Fail"
Range("H2").Formula = "C200 legacy Flux"
Range("H3").Formula = "0.056"
Range("F3").Formula = "=IFERROR(AVERAGEIF(Table6[Magnetization (wb)],""<>0""), ""No data entered"")"
Range("G3").Formula = "=IF(($F$3=""No data entered""),""N/A"",(IF(($F$3)>($H$3),""PASS"", ""FAIL"")))"
Dim LS As Long
LS = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$F$2:$H$3"), , xlYes).Name = "Table7"
End Sub
Sub Fuel_ready()
'Dim Time As Range
'Set Time = Sheets("Data Recording").Range("Table3[[#All],[Control Time ]]")
' Pasting initial Info Columns:
Sheets("RawData").Select 'Selects main data records sheet
Range("Table3[[#All],[Control Time ]]").Select 'Selects the entire 'Control Time' Column
Selection.Copy 'Copies it
Sheets("Fuel").Select 'Selects the 'Fuel' Sheet
Range("B7").Select 'Selects B7 (the location where I want this pasted from (row number is important to match the data record sheet)
ActiveSheet.Paste 'Pastes the 'control time' column
'Range("B7").Copy Sheets("Data Recording").Range("Table[[#All],[Control Time]]") 'doesnt work
'Worksheets("Fuel 2").Range("B7").Value = Worksheets("Data recording").Range("Table[[#All],[Control Time]]").Value 'doesnt work
'wb.Sheets("Data Recording").Range("Table3[[#All],[Control Time]]").Copy
'Selection.Copy
'wb.Sheets("Fuel 2").Range("B7").Paste
Sheets("RawData").Select 'Selects main data records sheet
Range("Table3[[#All],[System State ]]").Select 'Selects the entire 'System State' Column
Application.CutCopyMode = False 'Clears the Clipboard (this stops the 'large amount of information' error
Selection.Copy 'Copies it
Sheets("Fuel").Select 'Selects the 'Fuel' Sheet
Range("C7").Select 'Selects C7 (the location where I want this pasted to (row number is important to match the data record sheet)
ActiveSheet.Paste 'Pastes the 'System State'column
Sheets("RawData").Select 'Selects main data records sheet
Range("Table3[[#All],[Fuel Inlet Pres (kPa)]]").Select 'Selects the entire 'Fuel Inlet Pressure' Column
Application.CutCopyMode = False 'Clears the Clipboard (this stops the 'large amount of information' error
Selection.Copy 'Copies it
Sheets("Fuel").Select 'Selects the 'Fuel' Sheet
Range("F7").Select 'Selects D7 (the location where I want this pasted from (row number is important to match the data record sheet)
ActiveSheet.Paste 'Pastes the 'Fuel Pressure'column
Sheets("RawData").Select 'Back to main data records sheet
Range("Table3[[#All],[Turbine Exit Temp (°C)]]").Select 'Selects the entire 'TET Average' Column
Application.CutCopyMode = False 'Clears the Clipboard (this stops the 'large amount of information' error
Selection.Copy 'Copies the Gen Speed Column
Sheets("Fuel").Select 'Goes back to the Magnet sheet
Range("H7").Select 'Selects cell C7 (where I want the data pasted)
ActiveSheet.Paste 'Pastes the data
Sheets("RawData").Select 'Back to main recording
Range("Table3[[#All],[FCB Solenoid Command ]]").Select 'Selects the entire Gen Quadrature Voltage Column
Application.CutCopyMode = False 'Clears the clipboard
Selection.Copy 'Copies the Gen Quadrature Voltage
Sheets("Fuel").Select 'Selects Magnet sheet
Range("J7").Select 'Selects cell D7 (where I want to paste)
ActiveSheet.Paste 'Pastes the data
Range("B7").Select 'Selects cell B7 (the start of my in-a-minute table) (since added to the listobjects below)
' Now fill in the Heading gaps: 'For filling manual ranges
Range("D7").FormulaR1C1 = "Engine STATE Hex" 'Heading here, need to add the formula once table is formed below
Range("E7").FormulaR1C1 = "STATE" 'Column head for Plain English State (Using LOOKUP table)
Range("G7").FormulaR1C1 = "Pressure OK?" 'Too High/Too Low/Good Pressure
Range("I7").FormulaR1C1 = "TET OK?" 'Too High/Too Low/Good TET
Range("K7").FormulaR1C1 = "Remove 0x" 'Column with removed 0x prefix from solenoid command
Range("L7").FormulaR1C1 = "Binary Version" 'Inserts column to Convert the Hex from the solenoid command into a single binary word for conversion
Range("M7").FormulaR1C1 = "(bit15)"
Range("N7").FormulaR1C1 = "(bit14)"
Range("O7").FormulaR1C1 = "Compressor (bit13)"
Range("P7").FormulaR1C1 = "(bit12)"
Range("Q7").FormulaR1C1 = "(bit11)"
Range("R7").FormulaR1C1 = "MainFan (bit10)"
Range("S7").FormulaR1C1 = "(bit9)"
Range("T7").FormulaR1C1 = "Igniter (bit8)"
Range("U7").FormulaR1C1 = "ShutOffVv1 (bit7)"
Range("V7").FormulaR1C1 = "Inj 6 (bit6)"
Range("W7").FormulaR1C1 = "Inj 5 (bit5)"
Range("X7").FormulaR1C1 = "Inj 4 (bit4)"
Range("Y7").FormulaR1C1 = "Inj 3 (bit3)"
Range("Z7").FormulaR1C1 = "Inj 2 (bit2)"
Range("AA7").FormulaR1C1 = "Inj 1 (bit1)"
Range("AB7").FormulaR1C1 = "ShutOffVv2 (bit0)" 'Inserts all the bit columns (the unused ones I will probably need code to hide afterwards)
'Create the table:
Dim LR As Long
LR = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$B$7:$AB" & LR), , xlYes).Name = "Table8"
'Create the reference tables
'need column AE to be Test:
Range("AE1:AE32").NumberFormat = "@"
'table 19 is the state translator
Range("AE4").Formula = "State"
Range("AF4").Formula = "Plain English"
Range("AE5").Formula = "00"
Range("AE6").Formula = "01"
Range("AE7").Formula = "02"
Range("AE8").Formula = "03"
Range("AE9").Formula = "04"
Range("AE10").Formula = "05"
Range("AE11").Formula = "06"
Range("AE12").Formula = "07"
Range("AE13").Formula = "08"
Range("AE14").Formula = "09"
Range("AE15").Formula = "0A"
Range("AE16").Formula = "0B"
Range("AE17").Formula = "0C"
Range("AE18").Formula = "0D"
Range("AE19").Formula = "0E"
Range("AE20").Formula = "0F"
Range("AE21").Formula = "10"
Range("AE22").Formula = "11"
Range("AF5").Formula = "Not Connected"
Range("AF6").Formula = "Standby"
Range("AF7").Formula = "Prepare to Start"
Range("AF8").Formula = "Lift-Off"
Range("AF9").Formula = "Prepare to Light"
Range("AF10").Formula = "Acceleration"
Range("AF11").Formula = "Run"
Range("AF12").Formula = "Load"
Range("AF13").Formula = "ReCharge"
Range("AF14").Formula = "Cooldown"
Range("AF15").Formula = "Warmdown"
Range("AF16").Formula = "Restart"
Range("AF17").Formula = "Shutdown"
Range("AF18").Formula = "Fault"
Range("AF19").Formula = "Disable"
Range("AF20").Formula = "Bad Config"
Range("AF21").Formula = "Download"
Range("AF22").Formula = "Idle Recharge"
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$AE$4:$AF$22"), , xlYes).Name = "Table19"
'Table 26 is the max/min kpa
Range("AE24").Formula = "Max/Min"
Range("AE25").Formula = "Fuel Pressure Min"
Range("AE26").Formula = "Fuel Pressure Max"
Range("AF24").Formula = "kpa"
Range("AF25").Formula = "517"
Range("AF26").Formula = "552"
Range("AG24").Formula = "OK"
Range("AG25").Formula = "Too Low"
Range("AG26").Formula = "Too High"
Range("AH24").Formula = "Psi"
Range("AH25").Formula = "75"
Range("AH26").Formula = "80"
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$AE$24:$AH$26"), , xlYes).Name = "Table26"
'Table 27 is the max/min temp
Range("AE28").Formula = "Max/Min"
Range("AE29").Formula = "TET Average Min"
Range("AE30").Formula = "TET Average Max"
'this 07 wont work unless i format the cell to text first
Range("AE31").Formula = "07"
Range("AF28").Formula = "degC"
Range("AF29").Formula = "629"
Range("AF30").Formula = "641"
Range("AF31").Formula = ""
Range("AG28").Formula = "OK"
Range("AG29").Formula = "Too Low"
Range("AG30").Formula = "Too High"
Range("AG31").Formula = "Not in Load"
Range("AH28").Formula = "degF"
Range("AH29").Formula = "1165"
Range("AH30").Formula = "1185"
Range("AH31").Formula = ""
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$AE$28:$AH$31"), , xlYes).Name = "Table27"
'Fill the bespoke page formula into the table (by inserting the formula in the top cell of each column):
Range("D8").FormulaR1C1 = _
"=RIGHT([@[System State ]],2)"
'Creates formula to read turbine state, just last two digits of mode/state hex
Range("E8").FormulaR1C1 = _
"=VLOOKUP([@[Engine STATE Hex]],Table19,2,FALSE)"
'Creates formula to write plain english states from the lookup table (Table 19)
Range("G8").Formula = _
"=IF(([@[Fuel Inlet Pres (kPa)]=]=>$AF$25),(IF(([@[Fuel Inlet Pres (kPa)]=]=>$AF$26),$AG$26,$AG$24)),$AG$25)"
'Creates formula to write plain english indication of fuel from AB25 and 26
Range("I8").Formula = _
"=IF(([@[STATE]]=""LOAD""),(IF(([@[Turbine Exit Temp (°C)]=]=>$AF$29),(IF(([@[Turbine Exit Temp (°C)]=]=>$AF$30),$AG$30, Table27[[#Headers],[OK]])),$AG$29)),$AG$31)"
'Creates formula to write plain english indication of TET from AB25 and 26
Range("K8").Formula = _
"=RIGHT([@[FCB Solenoid Command ]],4)"
'Creates formula to remove 0x prefix
Range("L8").Formula = _
"=CONCATENATE(HEX2BIN(LEFT([@[Remove 0x]],2),8),HEX2BIN(RIGHT(RIGHT([@[Remove 0x]],4),2),8))"
'Writes full 16bit binary version of sol. command
Range("M8").Formula = "=MID([@[Binary Version]],COLUMNS($K3:K3),1)"
Range("N8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:E1),1)"
Range("O8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:F1),1)"
Range("P8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:G1),1)"
Range("Q8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:H1),1)"
Range("R8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:I1),1)"
Range("S8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:J1),1)"
Range("T8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:K1),1)"
Range("U8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:L1),1)"
Range("V8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:M1),1)"
Range("W8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:N1),1)"
Range("X8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:O1),1)"
Range("Y8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:P1),1)"
Range("Z8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:Q1),1)"
Range("AA8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:R1),1)"
Range("AB8").Formula = "=MID([@[Binary Version]],COLUMNS($D1:S1),1)"
'Split up binary into individual bits
'Hide Columns:
Columns(3).Resize(, 2).Select
Selection.EntireColumn.Hidden = True
'Hides the System state with 0x prefix column and the State hex
Columns(10).Resize(, 3).Select
Selection.EntireColumn.Hidden = True
'Hides sol command, Hex with 0x removed column and binary equivalent column
Range("B7").Select
End Sub
Sub Diff_Press()
Sheets("RawData").Select 'Selects main data records sheet
Range("Table3[[#All],[Diff Air Pressure (kPa)]]").Select 'Selects the entire 'Control Time' Column
Selection.Copy 'Copies it
Sheets("Engine Air Filter").Select 'Selects the 'Engine Air Filter' Sheet
Range("B7").Select 'Selects B7 (the location where I want this pasted from (row number is important to match the data record sheet)
ActiveSheet.Paste 'Pastes the 'Differential Air Pressure'column
Dim LR As Long
LR = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$B$7:$B" & LR), , xlYes).Name = "Table9"
Range("F2").Formula = "Average Differential Pressure"
Range("G2").Formula = "Pass or Fail"
Range("H2").Formula = "Maximum Diff."
Range("H3").Formula = "2"
Range("F3").Formula = "=IFERROR(AVERAGEIF(Table9[Diff Air Pressure (kPa)],""<>0""), ""No Data Entered/Recorded"")"
Range("G3").Formula = "=IF(($F$3=""No data entered""),""N/A"",(IF(($F$3)<($H$3),""PASS"", ""FAIL"")))"
Dim LS As Long
LS = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$F$2:$H$3"), , xlYes).Name = "Table10"
End Sub
Sub LowV_Ready()
Sheets("RawData").Select
Range("Table3[[#All],[Power Supply Voltage (V)]]").Select
Selection.Copy
Sheets("24V Supplies").Select
Range("B7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[FCM Switch Power (Vdc)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("24V Supplies").Select
Range("C7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[FCM Pwr Supply (Vdc)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("24V Supplies").Select
Range("D7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[FCM 5.0 V (Vdc)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("24V Supplies").Select
Range("E7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[FCM 2.5 VREF (Vdc)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("24V Supplies").Select
Range("F7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[FCB Control Power Supply (V)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("24V Supplies").Select
Range("G7").Select
ActiveSheet.Paste
Range("B7").Select
Sheets("RawData").Select
Range("Table3[[#All],[FCB Switched Power Supply (V)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("24V Supplies").Select
Range("H7").Select
ActiveSheet.Paste
Range("B7").Select
Sheets("RawData").Select
Range("Table3[[#All],[FCB 5V Analog Power (V)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("24V Supplies").Select
Range("I7").Select
ActiveSheet.Paste
Range("B7").Select
Sheets("RawData").Select
Range("Table3[[#All],[FCB 2.5V ADC Ref (V)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("24V Supplies").Select
Range("J7").Select
ActiveSheet.Paste
Range("B7").Select
Dim LR As Long
LR = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$B$7:$J" & LR), , xlYes).Name = "Table11"
End Sub
Sub Temperatures_ready()
'
' Electronic Temperatures_ready Macro
'
Sheets("RawData").Select
Range("Table3[[#All],[Main Board Temp (°C)]]").Select
Selection.Copy
Sheets("ElectronicTemp").Select
Range("B7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Bat Therm.Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("C7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Bat PM Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("D7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[BC Heatsink T (°C)]]").Select
Selection.Copy
Sheets("ElectronicTemp").Select
Range("E7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[BC Board T (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("F7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Inv Heat Sink Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("G7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Brake Temp (°C)]]").Select
Selection.Copy
Sheets("ElectronicTemp").Select
Range("H7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[CHP Board Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("I7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[FCM Board Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("J7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[FCM Cold Junc T (°C)]]").Select
Selection.Copy
Sheets("ElectronicTemp").Select
Range("K7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Gen IGBT A Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("L7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Gen IGBT B Ttemp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("M7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Gen IGBT C Temp (°C)]]").Select
Selection.Copy
Sheets("ElectronicTemp").Select
Range("N7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Gen IGBT Brake Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("O7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Gen ICB Board Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("P7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Gen PDM1 Board Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("Q7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Gen PDM2 Board Temp (°C)]]").Select
Selection.Copy
Sheets("ElectronicTemp").Select
Range("R7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Inv IGBT A Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("S7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Inv IGBT B Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("T7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Inv IGBT C Temp (°C)]]").Select
Selection.Copy
Sheets("ElectronicTemp").Select
Range("U7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Inv IGBT N Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("V7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Inv ICB Board Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("W7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Sec Bat Therm.Temp (°C)]]").Select
Selection.Copy
Sheets("ElectronicTemp").Select
Range("X7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Sec Bat PM Temp (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("Y7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Sec BC Heatsink T (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("Z7").Select
ActiveSheet.Paste
Sheets("RawData").Select
Range("Table3[[#All],[Sec BC Board T (°C)]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("ElectronicTemp").Select
Range("AA7").Select
ActiveSheet.Paste
Range("B7").Select
Dim LR As Long
LR = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$B$7:$AA" & LR), , xlYes).Name = "Table12"
End Sub