473,831 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Replace Cell Value in formula as loop executes?

11 New Member
I'm sure I'm going to kick myself for this, but I just can't get the syntax right. Perhaps I'm a wee bit fried... anyway, hopefully one of you experts can set me straight again.

All I'm trying to do is increment a value in a formula as a loop exectues through a range. I can't put it in one cell and do a fill down throughout because I'll end up with inaccurate results. When I embed the api call in an if statement, only about 75% of them execute - so I'm basically looking for that 25% and refiring the call.

Here's what I have:

Expand|Select|Wrap|Line Numbers
  1. For i = 1 To 10000 Step 1
  2.  
  3. Range("F" & i).Select
  4. If ActiveCell.Value = "#N/A Requesting Data..." Then
  5.     ActiveCell.formula = "=BDP(A2&"" Equity"", ""best_eps"",""best_fperiod_override"",""1fy"",""best_data_source_override"",XRef!$D$1,""best_consolidated_override"",""C"")"
  6.  
  7.     End If
  8. Next i
  9.  
  10.  
I just want to replace the A2 in :ActiveCell.for mula = "=BDP(A2&""
with A& the loop execution number.

I'm sure this is basic, but like I said, I'm fried! Thanks for any help!
Oct 7 '08 #1
2 4362
MikeTheBike
639 Recognized Expert Contributor
I'm sure I'm going to kick myself for this, but I just can't get the syntax right. Perhaps I'm a wee bit fried... anyway, hopefully one of you experts can set me straight again.

All I'm trying to do is increment a value in a formula as a loop exectues through a range. I can't put it in one cell and do a fill down throughout because I'll end up with inaccurate results. When I embed the api call in an if statement, only about 75% of them execute - so I'm basically looking for that 25% and refiring the call.

Here's what I have:

Expand|Select|Wrap|Line Numbers
  1. For i = 1 To 10000 Step 1
  2.  
  3. Range("F" & i).Select
  4. If ActiveCell.Value = "#N/A Requesting Data..." Then
  5.     ActiveCell.formula = "=BDP(A2&"" Equity"", ""best_eps"",""best_fperiod_override"",""1fy"",""best_data_source_override"",XRef!$D$1,""best_consolidated_override"",""C"")"
  6.  
  7.     End If
  8. Next i
  9.  
  10.  
I just want to replace the A2 in :ActiveCell.for mula = "=BDP(A2&""
with A& the loop execution number.

I'm sure this is basic, but like I said, I'm fried! Thanks for any help!
Hi

Perhaps somethink like
Expand|Select|Wrap|Line Numbers
  1. For i = 1 To 10000 
  2.     If Cells(i,6) = "#N/A Requesting Data..." Then
  3.         Cells(i,6) = "=BDP(A”  & i & """ Equity"", ""best_eps"",""best_fperiod_override"",""1fy"",""best_data_source_override"",XRef!$D$1,""best_consolidated_override"",""C"")" 
  4.    End If 
  5. Next i 
??

MTB
Oct 8 '08 #2
JP Romano
11 New Member
Mike - thanks a million - will give it a shot today and see how it works out. Appreciate the help!
Oct 8 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3728
by: jack | last post by:
I'm using VBA for Excel and would like to do the following: 1) in sheet1, search for a value which is given in a specific cell location on sheet2. 2) when i find that value in sheet1, i want to insert in the cell immediately to the right of the active cell a formula which includes a reference to a fixed cell location from sheet2 3) then i want to do the same search again in sheet1, this time using the
5
7235
by: Mads Petersen | last post by:
Hi, and thanks for previous help. I use following code to export from excel to access. It is executed in excel. I have an excel spreadsheet with one sheet pr. week. this code is therefore executed on every sheet, and is supposed to be it on comming sheets as well. Therefore I would very much like if I could check if the value in A98 (excel) matches a record in the access table TimeReview, field "Uge". And if it does the export should be...
3
10379
by: Dixie | last post by:
I wish basically to put the following formula into cell L6 in an excel spreadsheet.=COUNTIF(L6:L1025,"Yes"). I have tried the following code and it wont compile. the colon : is unacceptable. xl.ActiveCell.Value =COUNTIF(L6:L1025,"Yes") In fact, I have 3 different formulae, I want to do this with, but each fails on the colon.
1
3555
by: Thanks | last post by:
I have a routine that is called on Page_Init. It retrieves folder records from a database which I display as Link Buttons in a table cell. I set the table cell's bgcolor to a default color (say black for example). I am dynamically creating the LinkButton controls and adding them into the table cell and I've also hooked up an event handler for each LinkButton's Click event. This all works fine. Now in the Link Button's Click event...
1
1427
by: zafar | last post by:
I need to replace a cell value in grid e.g i have field "user_gender" of data type int where 1 means male and 0 means female. i did not make parent table for "gender", because there is only 2 possible records in table. i am assuming 1 and 0 as male and female. i need; when data is retrieved from database all 0's must be replaced with "Female" and all 1's must be replaced with "Male". One solution is this; that we use counter loop and...
1
1331
by: Brian Lundell | last post by:
Hi. My name is Brian Lundell. I am not a programmer, but very interested. I am creating a program for keeping track of Service Requests at work and am trying to find a way to automate creating a certain segment of code. The problem is as follows: I have created two worksheets in Excel. Cell G1 in the first needs to contain a formula to equal Cell A6 in the second. Cell G6 in the first needs to contain a formula to equal Cell A61 in the...
0
1865
by: suresh_punniyakkodi | last post by:
Hellow Friends, I have one doubt, please help me... In Excel, i have lot of rows and coloumns, i need to read all cell values with in rows and coloumn limit... At the time of read data from excel, Invalid use of Null error came... In that current cell have an '#VALUE!" -> that means illegal value... I need to read same '#VALUE!"(exact cell value from excel)... #VALUE! -> means, formula error... But, i need to read...
4
1741
by: SirCodesALot | last post by:
Hi All, I am trying to dynamically replace a table in the dom, anyone have an idea on how to do this. here is some sample suedo code of what I want to do. var tableHTML = "<table id=\"table1\"><tr><td>this is table 1</td></ tr></table>"; var tableHTML2 = "<table id=\"table2\"><tr><td>this is table 2</td></
1
11062
by: Monusonu | last post by:
Hi Expert, I am trying to get the value from excel formula cell using POI. My code works fine for less complex formula cells, but fails or returns error code for complex formula cells. Following is the code I am using to get values:- public class POIMain{ public POIMain() { } public static void main(String args) { try{
0
9794
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10778
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10496
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10210
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9319
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7750
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3077
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.