Sub PerformDiluentCalcs_()
Application.ScreenUpdating = False
Dim ws As Worksheet
Set ws = ActiveSheet
Dim sheettbl As ListObject
Dim formulaColumn As Range
Dim optPlate As Object
Dim optCell As Object
Set optPlate = ws.OLEObjects("optPlate").Object
Set optCell = ws.OLEObjects("optCell").Object
If optPlate.value = True Then
ElseIf optCell.value = True Then
Else
MsgBox "Please select an UV Analysis Method before proceeding."
Exit Sub
End If
If Not optPlate.value And Not optCell.value Then
MsgBox "Please select an UV Analysis Method before proceeding."
Exit Sub
End If
Dim querywb As Workbook
Set querywb = Workbooks.Open(Filename:="https://dtxpharma.sharepoint.com/:x:/s/Chemistry/EZxDgGlrMDlIvqQ9BP0sy64BybrMtMzXGByS-HNMCblVaA?e=Hn4Haq", ReadOnly:=True, UpdateLinks:=False)
querywb.Windows(1).Visible = False
Dim headers As Variant
headers = Array("Vol_Req", "Unit of Vol_Req", "Conc_Req", "Unit of Conc_Req", "Study Type", "Convert Vol Unit?", _
"Standardized Vol + DispExtra", "Standardized Conc (uM)", "umol requested", "Amount to Retain", "Auto DF", _
"Theo Abs AutoDF", "Chosen DF", "Theo Abs of Chosen DF", _
"DF QC Volume (uL)", "Vol for 6 QC", "Vol to Prep (uL)", "umol in prep", "mg (UV) in prep", "multiple preps?", "min umol req'd (stock)", _
"mg (UV) in stock", "UV/dry mass ratio", "adj factor (inverse of ratio)", "total mg to weigh(single_lineitem)", "total mg to weigh (grouped)", "Protic MW", "Ex Co", "Target", "Requested Volume", "Requested Concentration")
Dim i As Integer
For i = 0 To UBound(headers)
Range("K11").Offset(0, i).value = headers(i)
Next i
Rows(11).RowHeight = 45
Rows(11).WrapText = True
Rows(11).HorizontalAlignment = xlCenter
Rows(11).VerticalAlignment = xlVAlignTop
Range("G12").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.TextToColumns Destination:=Range("K12"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=True, Other:=True, OtherChar:= _
"@", FieldInfo:=Array(Array(1, 1), Array(2, 2), Array(3, 1), Array(4, 2)), _
TrailingMinusNumbers:=True
Set sheettbl = ActiveSheet.ListObjects(1)
Set formulaColumn = sheettbl.ListColumns(37).DataBodyRange
formulaColumn.Formula = "=VLOOKUP($A12,'https://dtxpharma.sharepoint.com/sites/Chemistry/Shared Documents/Oligo Manufacturing - Research/AS/Documents/Database Excels/DTx References/[2023Query.xlsx]GenConstructQuery'!$A$2:$D$16000,4,FALSE)"
Set formulaColumn = sheettbl.ListColumns(38).DataBodyRange
formulaColumn.Formula = "=VLOOKUP($A12,'https://dtxpharma.sharepoint.com/sites/Chemistry/Shared Documents/Oligo Manufacturing - Research/AS/Documents/Database Excels/DTx References/[2023Query.xlsx]GenConstructQuery'!$A$2:$E$16000,5,FALSE)"
Set formulaColumn = sheettbl.ListColumns(39).DataBodyRange
formulaColumn.Formula = "=VLOOKUP($A12,'https://dtxpharma.sharepoint.com/sites/Chemistry/Shared Documents/Oligo Manufacturing - Research/AS/Documents/Database Excels/DTx References/[2023Query.xlsx]Formulations'!$A$2:$C$16000,2,FALSE)"
Set formulaColumn = sheettbl.ListColumns(15).DataBodyRange
formulaColumn.Formula = "=IF(([@[Unit of Conc_Req]])=""mg/mL"", ""in vivo"", IF(([@[Unit of Conc_Req]])=""uM"",""in vitro"", """"))"
Set formulaColumn = sheettbl.ListColumns(16).DataBodyRange
formulaColumn.Formula = "=IF(([@[Unit of Vol_Req]])=""uL"", ""N"", ""Y"")"
Set formulaColumn = sheettbl.ListColumns(17).DataBodyRange
formulaColumn.Formula = "=IF(([@[Unit of Vol_Req]]=""uL""), [@[Vol_Req]]+10, IF(([@[Unit of Vol_Req]]=""mL""), ([@[Vol_Req]]*1000)+100, IF(([@[Unit of Vol_Req]]=""L""), ([@[Vol_Req]]*10^6)+1000,"""")))"
Set formulaColumn = sheettbl.ListColumns(18).DataBodyRange
formulaColumn.Formula = "=IF(([@[Unit of Conc_Req]])=""mg/mL"", [@[Conc_Req]]/[@[Protic MW]]*10^6, IF(([@[Unit of Conc_Req]])=""uM"",[@[Conc_Req]], """"))"
Set formulaColumn = sheettbl.ListColumns(19).DataBodyRange
formulaColumn.Formula = "=[@[Standardized Conc (uM)]]*[@[Standardized Vol + DispExtra]]/10^6"
......
querywb.Close SaveChanges:=False
ws.OLEObjects("optPlate").Visible = False
ws.OLEObjects("optPlate").Visible = True
ws.OLEObjects("optCell").Visible = False
ws.OLEObjects("optCell").Visible = True
Application.ScreenUpdating = True
Application.Calculate
Dim tbl As ListObject
Set ws = ActiveSheet
Set tbl = ws.ListObjects(1)
tbl.Sort.SortFields.Clear
tbl.Sort.SortFields.Add2 Key:=tbl.ListColumns("Requested Lot").DataBodyRange, _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
tbl.Sort.SortFields.Add2 Key:=tbl.ListColumns("Standardized Conc (uM)").DataBodyRange, _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With tbl.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.Apply
End With
End Sub