Consulting

Results 1 to 5 of 5

Thread: active cell formula typing

  1. #1
    VBAX Newbie
    Joined
    Mar 2009
    Posts
    4
    Location

    Arrow active cell formula typing

    hi
    i am very very new in VBA and like it very much
    i have started using it 2 days ago
    i am trying to understand the simplest syntaxis rules, and very confused many times
    my question is writing some formulas or different texts into a selected cell or range
    i can not understand the difference between. both work same for me
    can you please help me to understand. what is the purpose of R1C1 in first case, and what can be replaced there and what will change if we put smth else there

    thanks in advance
    1-

    Cells(2, 2).Select
    Selection.Activate
    ActiveCell.FormulaR1C1 = "not inkara"

    2 -
    Cells(2, 2).Select
    Selection.Activate
    ActiveCell.Formula = "not inkara"

  2. #2
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Hi there, and welcome to the board!

    First of all, you don't need to select a cell to do something with it. That is one of the first things you need to learn. This is done by almost every single beginner I've ever seen - including myself! You can shorten them to...

    Cells(2, 2).Value = "not inkara"
    A couple things to note.

    1) I used Value instead of Formula or FormulaR1C1. If you're just putting a value into a cell(s), then that is all you need. If you're putting in a formula, then use the Formula property. There is also a FormulaLocal and FormulaR1C1Local. The best thing I can tell you is to look it up in the Help files, which are invaluable to a coder.

    2) The basic differences between Formula and FormulaR1C1Local is the latter uses R1C1 style. If you look in the help files it should give an example of how they use it. You can use R1C1 reference style in a few different ways, both in a spreadsheet and in VBA. Basically it's a relative range which is based on the Row and Column.

    3) No need to Activate anything. Activating a range is like when you select a range, then act on that range. The acting on the range is the activation, i.e. entering a value/formula, or right clicking it. In code you can just cut to the chase and enter the Value/Formula.

    HTH

  3. #3
    VBAX Newbie
    Joined
    Mar 2009
    Posts
    4
    Location

    thanks a lot for your promt reply

    Quote Originally Posted by Zack Barresse
    Hi there, and welcome to the board!

    First of all, you don't need to select a cell to do something with it. That is one of the first things you need to learn. This is done by almost every single beginner I've ever seen - including myself! You can shorten them to...

    Cells(2, 2).Value = "not inkara"
    A couple things to note.

    1) I used Value instead of Formula or FormulaR1C1. If you're just putting a value into a cell(s), then that is all you need. If you're putting in a formula, then use the Formula property. There is also a FormulaLocal and FormulaR1C1Local. The best thing I can tell you is to look it up in the Help files, which are invaluable to a coder.

    2) The basic differences between Formula and FormulaR1C1Local is the latter uses R1C1 style. If you look in the help files it should give an example of how they use it. You can use R1C1 reference style in a few different ways, both in a spreadsheet and in VBA. Basically it's a relative range which is based on the Row and Column.

    3) No need to Activate anything. Activating a range is like when you select a range, then act on that range. The acting on the range is the activation, i.e. entering a value/formula, or right clicking it. In code you can just cut to the chase and enter the Value/Formula.

    HTH

  4. #4
    VBAX Newbie
    Joined
    Mar 2009
    Posts
    4
    Location
    thanks a lot for your quick reply and help

  5. #5
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    You're very welcome. If this solves if for you, please mark it as such from the Thread Tools | Mark Thread Solved | Perform Action.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •