Using offset to copy formula down a column

Awsib

New Member
Joined
Jan 6, 2020
Messages
1
Office Version
2016
Platform
Windows
Hi

I am trying to apply a formula where I need to refer to a few cells to the left of the formula cell and a few cells to the up and apply the formula down the column for quite a few rows.

I am trying to achieve the result by using offset function, but I am not getting the desired result.

I would be really grateful of any guidance.

VBA Code:
Sub ResultAchievedIsNotAsRequired()

Dim variableA As Long

variableA = Worksheets("DATA").Range("D7").Value

Dim LeftRow As Long

LeftRow = ActiveCell.Offset(0, -1).Value

Dim Upperrow As Long

Upperrow = ActiveCell.Offset(-1, 0).Value

Dim q As Long

Worksheet("MyCalculation").Range("B2").Select

For q = 5 To 10

Selection.Value = (ActiveCell.Offset(0, -1).Value * (2 / (VariableA + 1)) + ActiveCell.Offset(-1, 0).Value * (1 - (2 / (VariableA + 1))))

ActiveCell.Offset(1, 0).Activate

Next

End Sub
A somewhat similar formula may help in understanding my query better:-
Book1
EFGHI
9445.643,198,600445.64
10443.052,860,400443.05
11452.212,590,300452.21
12453.732,389,800453.73
13451.142,342,000451.14
14450.362,110,900450.36442.82
15457.102,543,100457.1444.86
16456.611,742,000456.61446.54
17453.941,712,500453.94447.60
18458.582,341,400458.58449.17
19462.281,995,200462.28451.04
20460.001,675,100460452.32
21444.892,620,200444.89451.26
22445.282,351,100445.28450.40
23443.972,255,000443.97449.48
24460.413,998,900460.41451.05
25465.243,560,500465.24453.07
26468.732,453,400468.73455.31
27471.372,341,000471.37457.60
MACD
Cell Formulas
RangeFormula
I14I14=SUM(E2:E14)/13
I15:I27I15=(E15*J$3)+(I14*(1-J$3))
 

Some videos you may like

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Watch MrExcel Video

Forum statistics

Threads
1,102,826
Messages
5,489,081
Members
407,671
Latest member
annep833

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top