computing
  • 0

(VBA): Select Cell at Left Side of Activecell

  • 0

Hello,

I need to select a cell at the left side of the active cell using an offset, as I’m working with dynamic ranges. When I do this, i.e:
Range(“B1”).Offset(0, -1).Select
selects both B1 and A1 cells, but i want it to select only A1 cell.

Googled it but haven’t found anything so far.

Any ideas?

Share

1 Answer

  1. I’m confused by your question.

    First you said that you want to select a cell at the left side of the active cell but your code is specific to B1.

    If I wanted to select a cell at the left side of the active cell I would use:

    ActiveCell.Offset(0, -1).Select

    That said, there’s 2 other things I’d like to mention:

    1 – When I use your code, it selects A1 only, not A1:B1.

    Try this and tell us what you get:

    MsgBox Range(“B1”).Offset(0, -1).Address

    It should return $A$1.

    2 – Why are you Selecting a cell? You rarely need to Select a cell via VBA in order to perform an operation on it.

    For example:

    Range("B1").Offset(0, -1).Select
    Selection.Formula = "=B1+C1"

    Can be reduced to:

    Range("B1").Offset(0, -1).Formula = "=B1+C1"

    You can typically perform the VBA operation directly on the Range from within VBA.

    It’s much more efficient/quicker.

    Click Here Before Posting Data or VBA Code —> How To Post Data or Code.

    • 0