0

I'm curious as to what is the difference between Sheet.Range.Value and Sheet.Range.Cells? I know that the former one is getting value from the specified range while the latter one I'm not quite sure. Does anyone know what it is?

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
user234568
  • 741
  • 3
  • 11
  • 21

1 Answers1

0

I answered this in the comments of your previous post. But here's the explanation again...

There is no "cell" of Range("F2:G2") or a value. F2:G2 is a Range of cells (or an array if you're thinking in python). Think of a column of cells in excel, if you entered the formula ="F2:G2" you wouldn't get a value. you must specify if you want to add, average, concatenate, etc.

The cells is a collection of all cells in the range. You can loop through them, count them, etc.

Here's an illustration:

Sub SubName()
    'put some text into cells A1:A3"

    Dim aCell As Range, helperText As String

    For Each aCell In Range("A1:A3").Cells
        'captures the value of each cell
        helperText = helperText & aCell.Value

        MsgBox "You are looping through the range and on cell " & aCell.Address _
        & ", and the concatenated result of this loop is " & helperText

    Next aCell

End Sub
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
pgSystemTester
  • 8,979
  • 2
  • 23
  • 49