Consulting

Results 1 to 2 of 2

Thread: How to add formula and value to cell VBA

  1. #1

    How to add formula and value to cell VBA

    Hola,

    I have the following code,

    [VBA]Dim c As Range
    Dim d As Range
    For Each c In Range("U" + row + ":BC" + row) '.End(xlToRight)
    For Each d In Range("U2:BC2")
    If d.Value >= eka And d.Value <= toka Then
    c.Value = 14
    End If
    Next d
    Next c
    [/VBA]
    In the range C there are formulas in every cell and now i want to add number 14 to the cell but i would not like to lose my formula from the cell, is that possible?

    - Antti

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Don't understand the double loops, but maybe

    [vba]

    Dim c As Range
    Dim d As Range

    For Each c In Range("U" + Row + ":BC" + Row) '.End(xlToRight)

    For Each d In Range("U2:BC2")
    If d.Value >= eka And d.Value <= toka Then

    c.Formula = c.Formula & "+14"
    End If
    Next d
    Next c[/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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