arrays


VBA: Referencing Arrays in Formula


I am trying to create a macro that loops through columns to apply a formula. In the last part of the formula, I need to multiply by a value. This value changes for each column (but is consistent for each row within the column).
I have attempted to define an array to do this (containing the different multipliers), but get a #NAME? error, and can see that the name of the array is appearing in the formula bar as opposed to the actual value. My code is below.
I appreciate the help - I'm very new at this!
Sub CotData()
Dim Rng1 As Range
Dim Element As Integer, ColNum As Integer
Dim slope_array As Variant
Set Rng1 = Sheets("Co(t) OREAS 901").Range("A48:A127")
ActiveWorkbook.Names.Add Name:="slope", RefersTo:=Rng1
Range("A1").Select
ActiveCell.Offset(2, 3).Range("A1").Select
slope_array = Range("slope")
Element = 0
For ColNum = 4 To 320
Element = Element + 1
ActiveCell.FormulaR1C1 = "=('Co(t) OREAS 901'!RC[-2])/('Co(t) OREAS
901'!RC[-1]* (slope_array(Element,1)))"
ActiveCell.Select
Selection.AutoFill Destination:=ActiveCell.Range("A1:A40")
ActiveCell.Range("A1:A40").Select
Next ColNum
End Sub

Related Links

How to search for multiple elements in Ruby array using regexp
Perl: equivalent of “ubound” in VBA
OptionsResolver: How to validate sub-options following an unknown options tree
Converting a UDF into an array UDF
How to make array values all capital letters lazarus
How do I separate unique and duplicate items from two arrays in perl?
My randomized Array list is not working
Sorting variable-length items / Algorithms
MongoDB : Single update on multiple fields V/S Multiple updates on single field?
Maximum difference between two elements is equal to solve Maximum Subarray?
Create an array from a CSV list
Finding the contents of an Array 'a' after the loop completes
How to replace a single character in a string?
perl find lines containing string 1 then extract character between string 2 and 3
ElasticSearch - why ScriptDocValues returns unique values?
How to loop through output of a command?

Categories

HOME
arrays
tensorflow
symfony
angular-cli
backup
sbt-assembly
propertygrid
xtext
histogrammar
android-source
jboss7.x
uiscrollview
local
pdo
bootstrap-popover
arm-template
quartus
pyephem
plupload
aws-cognito
multiple-columns
plsqldeveloper
esql
google-maps-android-api-2
autolayout
spring-ws
explode
nmf
searchbar
fabric
jflex
geopandas
jenkins-job-dsl
web-frontend
nesc
pygooglechart
jackson-dataformat-csv
helix-3d-toolkit
getline
receipt
modelandview
rhomobile
reactivemongo
mmdrawercontroller
bigcartel
socketpair
concrete5-5.7
linq-to-entities
intellij-idea-2016
ssh.net
stress-testing
aqgridview
dimple.js
shutdown
udev
volume
photon-controller
barcode-printing
radians
pax-web
qregexp
shipitjs
contour
multinomial
jenkins-scriptler
enyo
unity5.3
qbfc
sevenzipsharp
pyopengl
digits
uos
ember-cli-addons
pl-i
proximity
docopt
funq
valence
planetary.js
installshield-2009
multiple-login
haskell-platform
ienumerator
shiva3d
graph-coloring
process-monitor
static-variables
text-services-framework
signals2
msgbox
throttling
text-size
nemerle
executable-format
noir
gwt-2.2-celltable
pci-bus
visual-studio-2010-beta-2
hmacsha1
usergroups
divx

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App