What does ActiveCell do in VBA?

What does ActiveCell do in VBA?

So I was reading some help documents on ActiveCell and it states that it will return the value of the active cell.

It also states that you can use ActiveCell.Value for retrieving a value. However, it didn't really state why we would want to use it.

When I ran the following code in a module. Sub test(). MsgBox ActiveCell.Value End Sub. It returned the value of the cell. However, if I placed the MsgBox inside the Sub test, it didn't show anything. Why is this? What does the ActiveCell.Value actually do and what is the difference between using it or not.

ActiveCell is the name of the current active cell in your worksheet, including its contents (ie the number/value/format of the cell). So, this line: Gets the value of the current active cell. In other words, if the cell contains a number, then it will get the number back, otherwise it will get a blank string.

The line. Is the same as

How to offset active cell in VBA?

I need to be able to offset a cell in a column that is active in the VBA editor.

Here is my code so far, which should offset an active cell in the 5th column by 1.5
Option Explicit. Public Sub test(). Dim c As Range. Set c = Range("D1"). c.Offset(0.5, 0).Select

End Sub. Your code can also be written as. Set c = c.Resize(, 1).Offset(0, 1.5)
The difference is, of course, that this will apply to every single cell in column D (the 5th) and not just one, whereas your original code would do exactly the opposite.

Related Answers

What is the active cell represented by in Excel?

I mean, there's a cell with data in it, but it doesn't do anything...

What does ActiveCell value mean in VBA?

I am writing an excel macro to copy a section of an active cell...

How do I get the INDEX of a row in Excel VBA?

Is there any way to use INDEX MATCH with VBA/VSTO? This is what I've been wor...