2

I have a String value in A1.

Why is it that if I run the following code it captures the value correctly:

arrInputData(1, 1) = Worksheets("inputData").Range("A1")

However, a slight change to it

arrInputData(1, 1) = Worksheets("inputData").Range(Cells(1, 1), Cells(1, 1))

throws the following error:

Runtime error 1004. Application defined or object defined error

Thank you!

Community
  • 1
  • 1
hardish
  • 145
  • 2
  • 11

1 Answers1

2

arrInputData(1, 1) = Worksheets("inputData").Range(Cells(1, 1), Cells(1, 1))

is a shorter way of writing:

arrInputData(1, 1) = Worksheets("inputData").Range(ActiveSheet.Cells(1, 1), ActiveSheet.Cells(1, 1))

and will cause an error if "inputData" is not the active sheet

barrowc
  • 10,444
  • 1
  • 40
  • 53