N
N
Nikita072019-09-02 19:24:50
Macros
Nikita07, 2019-09-02 19:24:50

How to put the values ​​of the selected cells into an array?

Good afternoon, how to use VBA to enter the values ​​of the selected cells into an array for further use?
PS Cells with values ​​can have a different location, as in the picture below.
5d6d4238ea6e4274664696.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene Kuznetsov, 2019-09-13
@Nikita07

Selecting a range to enter

DIm DataCell as Range

On Error Resume Next
For Each DataCell in Selection
    If DataCell.Value<>0 Then 'При условии, что значения могут быть только числовые. Иначе делаем проверки или, как я, забиваем на них с помощью On Error Resume Next
        'Приченяем добро: добавляем данные в динамический массив, в коллекцию, в другие ячейки и т.п.
    End If
Next

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question