Results 1 to 3 of 3

Trying to add cells to my formula

Threaded View

WouterKoster Trying to add cells to my... 05-03-2022, 09:34 AM
KOKOSEK Re: Trying to add cells to my... 05-03-2022, 09:48 AM
WouterKoster Re: Trying to add cells to my... 05-03-2022, 09:56 AM
  1. #1
    Registered User
    Join Date
    04-26-2022
    Location
    Groningen
    MS-Off Ver
    Microsoft 365
    Posts
    4

    Question Trying to add cells to my formula

    Hello,

    So I've been using the following formula:

    Sub MacroAddOne()
    '
    ' MacroAddOne Macro
    '
        Dim r As Range: With Range("G15"): Set r = Cells(.Row, Columns.Count)(1): r.Formula = .Formula: r.Copy r(2): .Cells(1).Formula = r(2).Formula: r.Resize(2).Clear: End With
        
    End Sub
    This formula adds changes the formula in G15 from '=(B11-B10)/B10' to ='(B12-B11)/B11'.

    Now I want to add the cells G16, G17 and G18 to this formula aswell, but I cant get it to work.

    The things I tried are:

    Dim r As Range: With Range("G15:G18"): Set r = Cells(.Row, Columns.Count)(1): r.Formula = .Formula: r.Copy r(2): .Cells(1).Formula = r(2).Formula: r.Resize(2).Clear: End With
    and:

    Dim r As Range: With Range("G15","G16","G17","G18"): Set r = Cells(.Row, Columns.Count)(1): r.Formula = .Formula: r.Copy r(2): .Cells(1).Formula = r(2).Formula: r.Resize(2).Clear: End With
    These both didn't work.

    Please let me know what im doing wrong.

    Thanks in advance!
    Last edited by WouterKoster; 05-03-2022 at 09:57 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 05-12-2021, 01:22 PM
  2. [SOLVED] Simple formula needed to count cells based on item names in other cells
    By excelteam777 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-25-2019, 05:49 PM
  3. [SOLVED] Formula to return N for cells with 0 and empty cells, and Y for cells with data
    By stpeter in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-13-2016, 05:20 PM
  4. Replies: 2
    Last Post: 05-14-2015, 03:19 PM
  5. Formula needed for dividing 2 sets of cells and excluding adjacent text cells
    By excelteam777 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-07-2013, 06:45 PM
  6. Replies: 1
    Last Post: 11-20-2012, 10:08 AM
  7. Formula: Drop Down List -> Choose Option Finds Cells & Replace Cells with Cells
    By g00glethis1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-14-2010, 01:10 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1