hi
im using thses line of code to pull stuff of an excel sheet
but sometime some spreadsheets wont have the word class b in it but i get an error if it doesnt. i want to put in an if statement so if its null to go to next piece of code.Code:oRng = oWSSheet2.Cells.Find("Class B", , _ Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlPart, _ Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, False) ' MsgBox("Value '" & app oRng.Value & "' found at '" & oRng.Address) Me.classb = oRng.Offset(0, 42).Value oRng = Nothing
how can this be done in vb
if i try this
if orng is not null then
Me.classb = oRng.Offset(0, 42).Value
else
....
but that's not quite right




Reply With Quote