Run-time error '438': Object doesn't support this property of meth

G

Guest

The line that start with "Set cRange" (last line) in this code gave me a
Run-time error '438': Object doesn't support this property or method. Anybody
can help me? Will be appreaciated, thanks.

Set wsStandards = Workbooks.Open(Filename:=stFullName)
Set wsSystem = ThisWorkbook.Sheets(TextBox1.Text)
'Set wsStandards = Sheets("Standards")

wsSystem.Activate
nLastRow = wsSystem.Cells(nFirstRow, 2).End(xlDown).Row
nLastRow2 = wsSystem.Cells(nFirstRow, 2).End(xlDown).Row
vCompType = wsSystem.Range(wsSystem.Cells(nFirstRow, 2),
wsSystem.Cells(nLastRow, 2))
vStanType = wsSystem.Range(wsSystem.Cells(nFirstRow, 11),
wsSystem.Cells(nLastRow, 11))

For m = 1 To nLastRow + 1 - nFirstRow
If InStr(1, CStr(vStanType(m, 1)), "NC", vbTextCompare) = 0 Then
Set cRange = Nothing

Set cRange =
wsStandards.Columns("B").Find(What:=CStr(vCompType(m, 1)),
After:=wsStandards.Cells((nFirstRow - 1), 2), _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, MatchCase:=False)
 
P

par_60056

The line that start with "Set cRange" (last line) in this code gave me a
Run-time error '438': Object doesn't support this property or method. Anybody
can help me? Will be appreaciated, thanks.

Set wsStandards = Workbooks.Open(Filename:=stFullName)
Set wsSystem = ThisWorkbook.Sheets(TextBox1.Text)
'Set wsStandards = Sheets("Standards")

wsSystem.Activate
nLastRow = wsSystem.Cells(nFirstRow, 2).End(xlDown).Row
nLastRow2 = wsSystem.Cells(nFirstRow, 2).End(xlDown).Row
vCompType = wsSystem.Range(wsSystem.Cells(nFirstRow, 2),
wsSystem.Cells(nLastRow, 2))
vStanType = wsSystem.Range(wsSystem.Cells(nFirstRow, 11),
wsSystem.Cells(nLastRow, 11))

For m = 1 To nLastRow + 1 - nFirstRow
If InStr(1, CStr(vStanType(m, 1)), "NC", vbTextCompare) = 0 Then
Set cRange = Nothing

Set cRange =
wsStandards.Columns("B").Find(What:=CStr(vCompType(m, 1)),
After:=wsStandards.Cells((nFirstRow - 1), 2), _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, MatchCase:=False)

I think that your problem comes from having the 3rd line commented out
so wsStandards is a workbook not a worksheet.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top