Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the current cell in Excel VB

Tags:

excel

vba

I have a small script in Excel/VB that I'm trying to get working. All I want to do is select a dynamic range of data to copy but I can't seem to find any help/code on how to get the grid data (like A11).

Here is code I have from macro recording that selects the range of data:

Range("D291:D380").Select

I was hoping I could just do Range(Current).Select or something but that doesn't work.

How do I get the current cell using VBA?


1 Answers

Have you tried:

For one cell:

ActiveCell.Select

For multiple selected cells:

Selection.Range

For example:

Dim rng As Range
Set rng = Range(Selection.Address)
like image 62
Ben McCormack Avatar answered Sep 09 '25 23:09

Ben McCormack