Xav Rouss
Xav Rouss

Reputation: 1

Type mismatch error when copying cells from another workbook

I'm having a type mismatch error when I try to copy a cell from a workbook. Any idea as to what is wrong here ?

 Workbooks(inv).Sheets(sheetname).Cells(r.Row, price.Column).Copy

inv is a workbook, sheetname is a string, r is a range containing a single cell, price is a range containing a single cell. The content of the cell I'm trying to copy is a numeric value.

Upvotes: 0

Views: 459

Answers (1)

Tim Williams
Tim Williams

Reputation: 166316

If inv is a workbook object then:

inv.Sheets(sheetname).Cells(r.Row, price.Column).Copy

Your code as written would work if inv was a String

Upvotes: 4

Related Questions