Consulting

Results 1 to 5 of 5

Thread: Solved: goto a specific cell and insert text using vb

  1. #1

    Solved: goto a specific cell and insert text using vb

    i need to go to a specfic cell using a position I have grabbed using

    lastrow = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.UsedRange.Rows.Count

    totaltext = lastrow + 2

    I need to put TEXT in that cell in column G. then put a formula (=count(H1:Htotaltext) in the next cell over in column H

    how do I do that in VBA in excel? any help is appreciated

  2. #2
    VBAX Expert shrivallabha's Avatar
    Joined
    Jan 2010
    Location
    Mumbai
    Posts
    750
    Location
    Welcome to VBAX.
    To use formula:=
    [VBA]Range("G" & Totaltext).Formula = "=COUNT(H1:H" & TotalText & ")"[/VBA]
    There is another method documented in VBA as FormulaR1C1 which uses column and rows' number reference. You may look into it, if you want to.
    Regards,
    --------------------------------------------------------------------------------------------------------
    Shrivallabha
    --------------------------------------------------------------------------------------------------------
    Using Excel 2016 in Home / 2010 in Office
    --------------------------------------------------------------------------------------------------------

  3. #3

    thanks but one more question

    Thanks for the help. How do I place text such as "Totals" in the specific cell G:totaltext. Thanks for the one for the formula in the example you sent.

  4. #4
    VBAX Expert shrivallabha's Avatar
    Joined
    Jan 2010
    Location
    Mumbai
    Posts
    750
    Location
    You need to tell VBA that the item being inserted is value. Like:
    [VBA]Range("G" & Totaltext).Value = "Total"[/VBA]
    Be sure that you cover text with double quotes.
    Regards,
    --------------------------------------------------------------------------------------------------------
    Shrivallabha
    --------------------------------------------------------------------------------------------------------
    Using Excel 2016 in Home / 2010 in Office
    --------------------------------------------------------------------------------------------------------

  5. #5

    Cool Works like a charm. Thanks!!!

    works great. thanks for the help

Posting Permissions

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