Thanks for everyone's help...I could never get Mike's code to work, but I played around with my original code and did get the results I was looking for. May not be the cleanest, but it works for me.
I think it was a combination of the code and the spreadsheet not grabbing values properly. From what I read, spreadsheets with empty rows don't play nicely...I ended up putting the default values in the top row. If a row could not be found, it defaults to the first row after the headers.
Anyway, here's what I ended up with ....spreadsheet is at end.
SyntaxEditor Code Snippet
If Shape = "Rectangular Tube" Then
i = GoExcel.FindRow("C:\ENGINEERING\ilogic\Shape_Generator_Raw_Material_Specs.xlsx", "Rectangular_tube", "Matl", "=", Material, "Shape_Size", "=", Shape_Size)
Matl_Description = GoExcel.CurrentRowValue("Matl_Description")
M_Number = GoExcel.CurrentRowValue("M_Number")
' If Matl_Description = vbNullString Then Matl_Description = "Contact Engineering for Material"
' If M_Number = vbNullString Then M_Number = "Contact Engineering for Material"
iProperties.Value("Custom", "(Mat'l Description)") = Matl_Description
iProperties.Value("Custom", "(Reference M#)") = M_Number
InventorVb.DocumentUpdate()
Else If Shape = "Square Tube" Then
i = GoExcel.FindRow("C:\ENGINEERING\ilogic\Shape_Generator_Raw_Material_Specs.xlsx", "Square_tube", "Matl", "=", Material, "Shape_Size", "=", Shape_Size)
Matl_Description = GoExcel.CurrentRowValue("Matl_Description")
M_Number = GoExcel.CurrentRowValue("M_Number")
' If Matl_Description = vbNullString Then Matl_Description = "Contact Engineering for Material"
' If M_Number = vbNullString Then M_Number = "Contact Engineering for Material"
iProperties.Value("Custom", "(Mat'l Description)") = Matl_Description
iProperties.Value("Custom", "(Reference M#)") = M_Number
InventorVb.DocumentUpdate()
Else If Shape = "Plates" Then
i = GoExcel.FindRow("C:\ENGINEERING\ilogic\Shape_Generator_Raw_Material_Specs.xlsx", "Plates", "Matl", "=", Material, "Shape_Size", "=", Shape_Size)
Matl_Description = GoExcel.CurrentRowValue("Matl_Description")
M_Number = GoExcel.CurrentRowValue("M_Number")
' If Matl_Description = vbNullString Then Matl_Description = "Contact Engineering for Material"
' If M_Number = vbNullString Then M_Number = "Contact Engineering for Material"
iProperties.Value("Custom", "(Mat'l Description)") = Matl_Description
iProperties.Value("Custom", "(Reference M#)") = M_Number
InventorVb.DocumentUpdate()
Else If Shape = "Flat Bar" Then
i = GoExcel.FindRow("C:\ENGINEERING\ilogic\Shape_Generator_Raw_Material_Specs.xlsx", "Flat Bar", "Matl", "=", Material, "Shape_Size", "=", Shape_Size)
Matl_Description = GoExcel.CurrentRowValue("Matl_Description")
M_Number = GoExcel.CurrentRowValue("M_Number")
' If Matl_Description = vbNullString Then Matl_Description = "Contact Engineering for Material"
' If M_Number = vbNullString Then M_Number = "Contact Engineering for Material"
iProperties.Value("Custom", "(Mat'l Description)") = Matl_Description
iProperties.Value("Custom", "(Reference M#)") = M_Number
InventorVb.DocumentUpdate()
Else If Shape = "Mechanical Tube" Then
i = GoExcel.FindRow("C:\ENGINEERING\ilogic\Shape_Generator_Raw_Material_Specs.xlsx", "Mechanical_tube", "Matl", "=", Material, "Shape_Size", "=", Shape_Size)
Matl_Description = GoExcel.CurrentRowValue("Matl_Description")
M_Number = GoExcel.CurrentRowValue("M_Number")
' If Matl_Description = vbNullString Then Matl_Description = "Contact Engineering for Material"
' If M_Number = vbNullString Then M_Number = "Contact Engineering for Material"
iProperties.Value("Custom", "(Mat'l Description)") = Matl_Description
iProperties.Value("Custom", "(Reference M#)") = M_Number
InventorVb.DocumentUpdate()
Else If Shape = "Round Bar" Then
i = GoExcel.FindRow("C:\ENGINEERING\ilogic\Shape_Generator_Raw_Material_Specs.xlsx", "Round_bar", "Matl", "=", Material, "Shape_Size", "=", Shape_Size)
Matl_Description = GoExcel.CurrentRowValue("Matl_Description")
M_Number = GoExcel.CurrentRowValue("M_Number")
' If Matl_Description = vbNullString Then Matl_Description = "Contact Engineering for Material"
' If M_Number = vbNullString Then M_Number = "Contact Engineering for Material"
iProperties.Value("Custom", "(Mat'l Description)") = Matl_Description
iProperties.Value("Custom", "(Reference M#)") = M_Number
InventorVb.DocumentUpdate()
Else If Shape = "Hex" Then
i = GoExcel.FindRow("C:\ENGINEERING\ilogic\Shape_Generator_Raw_Material_Specs.xlsx", "Hex_bar", "Matl", "=", Material, "Shape_Size", "=", Shape_Size)
Matl_Description = GoExcel.CurrentRowValue("Matl_Description")
M_Number = GoExcel.CurrentRowValue("M_Number")
' If Matl_Description = vbNullString Then Matl_Description = "Contact Engineering for Material"
' If M_Number = vbNullString Then M_Number = "Contact Engineering for Material"
iProperties.Value("Custom", "(Mat'l Description)") = Matl_Description
iProperties.Value("Custom", "(Reference M#)") = M_Number
InventorVb.DocumentUpdate()
Else If Shape = "Channel" Then
i = GoExcel.FindRow("C:\ENGINEERING\ilogic\Shape_Generator_Raw_Material_Specs.xlsx", "Channel", "Matl", "=", Material, "Shape_Size", "=", Shape_Size)
Matl_Description = GoExcel.CurrentRowValue("Matl_Description")
M_Number = GoExcel.CurrentRowValue("M_Number")
' If Matl_Description = vbNullString Then Matl_Description = "Contact Engineering for Material"
' If M_Number = vbNullString Then M_Number = "Contact Engineering for Material"
iProperties.Value("Custom", "(Mat'l Description)") = Matl_Description
iProperties.Value("Custom", "(Reference M#)") = M_Number
InventorVb.DocumentUpdate()
Else If Shape = "Angle" Then
i = GoExcel.FindRow("C:\ENGINEERING\ilogic\Shape_Generator_Raw_Material_Specs.xlsx", "Angle", "Matl", "=", Material, "Shape_Size", "=", Shape_Size)
Matl_Description = GoExcel.CurrentRowValue("Matl_Description")
M_Number = GoExcel.CurrentRowValue("M_Number")
' If Matl_Description = vbNullString Then Matl_Description = "Contact Engineering for Material"
' If M_Number = vbNullString Then M_Number = "Contact Engineering for Material"
iProperties.Value("Custom", "(Mat'l Description)") = Matl_Description
iProperties.Value("Custom", "(Reference M#)") = M_Number
InventorVb.DocumentUpdate()
End If
Steve Hilvers
Inventor Certified User / Vault Professional Influencer