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ᴇʜ
  • 53,845
  • 9
  • 46
  • 68
user234568
  • 727
  • 3
  • 10
  • 17

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
  • 963,270
  • 265
  • 3,804
  • 3,187
pgSystemTester
  • 6,620
  • 2
  • 17
  • 43