VBA / Using Nested Loops To Expand Summarized Table?

Oct 14, 2013

As far as I can tell there needs to be a nested loop with some kind of variable inside a variable, but to be honest it's well beyond my current skill level... I have the file hosted on my Google Docs below.







View 3 Replies


Nested Loops..?

Aug 11, 2009

I seem to be having trouble creating a nested loop. It seemed simple enough in my brain holder, however, in real life...Well I am here aren't I. Here is my

View 2 Replies View Related

Nested Loops For Different Ranges

Mar 26, 2008

I have a basic while loop that does what I need it to do stand alone. Now I want to replace the 3 hard coded ranges (n51,r26,m26) with ranges that update during iteration #2. The new ranges for the while loop would be (n52,r27,m27). I will eventually have more than 2 iterations.

Sub Macro6()
' Macro6 Macro
' Macro recorded 3/19/2008 by User
' Keyboard Shortcut: Ctrl+g

Dim rng As Range, Acell As Range
Dim rng2 As Range, Bcell As Range
Dim rng3 As Range, Ccell As Range

View 3 Replies View Related

Enter Formula Using Two Summarized Values Within Pivot Table?

Jan 28, 2014

Is it possible to enter a formula using two summarized values within a pivot table?

For example, if the original column was "X" and within the pivot table i'm using "Sum of X" and then another for "Average of Y".

Can I then divide "Sum of X" by "Average of Y" or any other similar calculations between 2 summarized fields?

View 1 Replies View Related

Nested Do Loops With Find Next Capability

Jun 20, 2007

how to nest do loops with find next capability. I have written code (that does not work, of course) that I hope will explain what I am trying to do. The code error is something like 'Object needed'.


Selection.Find( _
What:="2", _

n5 = ActiveCell.Address

View 9 Replies View Related

Nested Loops. Start & End Loop

Dec 5, 2006

is there any body kind enough to look into this code and tell me from where the loop body starts and ends and which is the loop variable and how it is being incremented or decremented. i know it is a stupid question but i admit here that i learn and manage to update my sheets only because of this forum help, as i have absolutly no idea of VBA when i started some couple of months back but know i can do little bits.
thanx again for all the help i got so far and hope to get some solution this time as well

Sub LowRisk_Chart()
Voffset = 0
Vcounter1 = 2
Vline = Sheets("ChartWork"). Cells(Vcounter1, 1)
Vblocks = Sheets("ChartWork").Cells(Vcounter1, 4)
Vstdman = Sheets("ChartWork").Cells(Vcounter1, 5)
Vlength = Vblocks

View 3 Replies View Related

Nested For Each Loops Moving To Next Cell On Both Simultaneously?

Jan 29, 2014

I am trying to run 2 for each loops inside another loop, and I was wondering if there is a way to move to the next value for all loops at the same time.

So when it reaches "Next starting, final, scal", all ranges move to the next cell before performing the formula.

View 2 Replies View Related

Formula To Expand Headings To Table Columns

Jan 25, 2014

The attached workbook has a fragment of a table . The column heads are letters representing job nos. The first row is of numbers which will always be multiples of 1000. Subsequent rows are the factors of each number by each number.

My problem is how to structure the columns of the second table so that if a number has a factor of 1 there is one copy of that column head. if the number has a factor of 2 then there are 2 copies of the head, and so on.

The table can vary in size but the first row of each column will always be an integral number of 1000's (e.g. never 1250).

I have not been able to attach the workbook as "ADDFILES" is not visible in the download screen, I hope the above description will be enough.

View 3 Replies View Related

Pivot Table - Automatically Expand Range Selection Of Data

Oct 12, 2002

Possible to get a pivot table to automatically expand the range selection of data as it grows. I have a worksheet that grows daily and I am running a pivot table from this. If I refresh the pivot table it doesn't pick up new data unless i change the range or i have a huge range selected in the first place. Problem is if i select a huge range then the grouping options i am using won't work correctly.

View 5 Replies View Related

Expand Table To Include Missing Times From Data And Sort Based On Multiple Criteria

May 6, 2014

I have a set of data (assume 2 columns, one with a long name and the second with a time). The names contain variables that must be used as criteria (a single entry may contain "Blue" and "On"/"Off") and times vary, based on when the Name turns "On" or "Off" [in minutes: 25 (On), 47 (Off), 89 (On), 100 (Off) and 137 (On)]. I need to create another table that automatically inserts values for all times, to include the missing times (0 min thru 24 and 26 thru 46, etc.). EX: If the first entry is "Blue-On" at "25 minutes", the cells from 0 minutes to 24 minutes are each "0" and become a "1" at 25 minutes - the following cells are "1" until 47 minutes (where it is turned off). (1 and 0 represent "On" and "Off", respectively)

How can I created a formula to insert the correct numbers into the correct places? I'm willing to have multiple cells with formulas and simply hide the columns that are doing the calculations.

View 1 Replies View Related

Creating Summarized Product Lists?

Jan 28, 2013

I need a way to create summarized product lists from a large list of product.

Each product in the "full" list has the following rows: Product No., Name, Price, Quantity, Total.

I need the rows to copy to "sheet 2" when the total and/or quantity go above zero.

So on the new sheet I would end up with a list of products we need rather than having a whole sheet of all the products where the ones we need are mixed amongst the ones we don't.

View 9 Replies View Related

Excel 2010 :: Macro To Change Excel Formatted Table Name Dependent On Number Of Loops

Jul 9, 2012

Recorded macro. The hope is to insert a excel formatted table a set number of times. I have found a loop code that references a Cell A1 and repeats that amount of times. So if A1= 10. There should be 10 tables inserted. However on the second time there is a fault with the table name. I need the name to change each time the loop is run. ie Table1, Table2, Table3 etc up until the loop stops (A1 contents).

I am using excel for windows 2010. The macro that i have so far is below.

Sub LoopTest()
Dim n
Dim V
V = ActiveCell.Value

[Code] ........

View 1 Replies View Related

Nested If Statement For My Table

Apr 17, 2008

I am trying to write a nested if statement for my excel table. I calculated the betas of the stock portfolio. I would like to create an if statement that would do something like this:

if beta is less than 1 -- Below Average Risk
if beta is greater than 1 but less than 1.25 -- Average Risk
if beta is greater than 1.25 but less than 1.75 --Medium Risk
if beta is greater than 1.75 -- High Risk...

View 9 Replies View Related

Nested Formula (Sumif / Countif) - Sorting Table

Mar 6, 2013

It's actually a sumif/countif that works fine if i sort my table, which i don't want to do.

Here's the original formula:


I'm trying to apply the formula using some other filters, like if(C4:C35=O5 & I4:I35=M5).

I tried creating a SUMPRODUCT out of it but it was just as bad:


And also this with sum(if)


Is there a shorter formula that I'm not seeing ? I'm also confronted with the need of adding an "ISERROR" in the formula because not all ranges have the 1-4 numbers in column H.

View 9 Replies View Related

Nested Loop Not Working; Pulls Data From Multiple Files Into One Table

Aug 8, 2006

I've got this code that pulls data from multiple files into one table. the file name is in the top row, and each file's title, and two different sums display below that. Then it is supposed to loop through and display each task and the start and end date for that task within each file. After that the first loop brings it to the next column and file. The primary loop works fine, but the inner loop only seems to run once, as I get only the first result for each file. All I can figure is that maybe my row numbers aren't resetting like they're supposed to, or I'm completely overlooking something, which is likely, as VBA is by no means my forte.

Sub Worksheet_Calculate()
Dim sBook As String
On Error Resume Next
Application.EnableEvents = False
Col = 8
' Sets start column
sBook = Cells(2, Col)
' References file name
TaskRow = 6 ........................

View 5 Replies View Related

Nested IF (index And Match): Calculate A Charge In Cell K15 Based On Values In B9 And C10 Referencing The Table I8:R9

Jan 21, 2010

I'm trying to hone a quoting tool to generate an amount based on a given range and minimum charges for specified subsects of the range. If you reference the attachment I'm trying to calculate a charge in cell K15 based on values in B9 and C10 referencing the table I8:R9. What I cant figure out is how to create a minimum charge of 50 for J8:P9 (points A-G) and a charge of 95 for Q8:R9 (points H-I).

View 2 Replies View Related

Loops In Vba

Apr 13, 2007

how can i make a loop throught the G colum and to check if the cell before the currect is bigger/ lower or equal to the currect cell. and if its higher then an arrow will be shown '^' if its lower an upside down arrow will be show 'v'
equal will show -> arrow. example:

G2 = 200
G3 = ^ 300
G4 = -> 300
G5 = v 209

so how can i change the G3 to G4 G5 etc.. in a loop in the: Range("G3").Select command? and i need to change the

.Value = "=$G$2"
Value = "=$G$3"
Value = "=$G$4"
in 2 places................

View 4 Replies View Related

Macro That Loops

Oct 18, 2008

i have this code that upon opening of workboot it generates the next number thats available on sheet 2 i then enter the data that i need to and click the button it then transfers to sheet2 and prints 2 copies and then clears the cells that i have input data to

what i really need it to do is exactly as it does right now but to then change the next number available to what it is ....

View 14 Replies View Related

Using For Loops When Referencing

Aug 20, 2009

First of all, I'm completely new to both this forum and VBA. I have just done a programming course in java before. I hope you will forgive me if this have already been posted. No to my problem.

I am tryring to use different projected values to project other subparts of those units, which is done in the sheet mean needed weekly. Tje values are taken from projections. The answer that I get from mean needed weekly should be copied to a third sheet.

This is the code that I am using right know, but I cant get the for loop to work (or more exactly to be able to place the "i" in my text without making compilation errors).

View 9 Replies View Related

Eliminate Loops

Oct 9, 2009

One of the multitude of areas where I still need drastic improvement is with efficiency. Specifically, avoiding loops.

Are any of you aware of any good, basic level sites, blogs, posts, etc., about better methods or processes? I'm not particularly experienced with programming (I've been a software TESTER for 13 years and just started some programming in recent months), so the more basic the better.

View 2 Replies View Related

Loops With Formulas

Oct 2, 2008

I have recorded a macro that cleans up my data that I receive from an external source and inserts two columns.

I recorded a seperate macro to execute an "if formula" that evaluates Column A and B and if A is blank return the value in B, else return the value in A. I wrote the formula =if(a1=" ",b1,a1).

I referred to the text I got in the class and found that I can use a "Next Loop". I added to the formating macro the Next Loop critera and instead of inserting text I inserted the above formula.

It ran and returned data, however it was not in the column I intended, it cascaded off to the side of my data in a step down (kinda like stairs).

View 9 Replies View Related

VBA Colourindex & Do Loops

Nov 3, 2009

I need to maintain a KPI in excel2000 which details weekly progress, I normally do this using some condition formatting and hiding cells, I have to be honest its not pretty.

What I would like to do is to use the colorindex function to show the wk breakdown status and a Do loop on my target range, I think!...... I've a basic example below,

If I could show the benefits to my boss he might even let me take a VBA course.....

View 9 Replies View Related

Loops And Variables

Nov 10, 2009

I'm trying to better understand loops and variables. I have an instance I'd like to try and implement but I'm struggling with it. I know how to set a variable as 1 and loop through the code increasing the number each time but this one is a little different.

At the start of my code, I scan the worksheets for the worksheet names -

etc etc

and then assign these worksheets as

Monday = ws
Tuesday = ws2
Wednesday = ws3
etc etc

That way in my code I can do things to the workbooks like -

ws.Range("D4").Value = "blah blah"
and always know it will be tackling the right worksheet regardless of the sheets position in the workbook or sheetcode.

Well I have lots of changes to make on each of these sheets (Monday -> Sunday) which are identical. What I'd like to do is something like this -

VARIABLE.Range("D4").Value = "blah blah"

View 9 Replies View Related

Variables In For Loops

Oct 14, 2006

Is it possible to use a variable to change a controls name in a For Loop? I have several worksheet combo boxes that have the same root name, e.g., cbobox1, cbobox2. cbobox3, etc. I want to be able to keep the main name and change the numeric part in a for loop and also perform some function with the control. For example:

For x = 1 To 10
Next x

View 6 Replies View Related

Two Loops In One Module

May 7, 2007

Is it possible to do 2 loops in one procedure? I want to copy and paste formula the cells in one column and again in another column so I did two Do Loops. It only ran for the first loop but not on the second, although they have almost the same code (I just edited the column from C to I). Please see below

Dim RowCount As Integer

Sub Format()
Selection.Insert Shift:=x1ToRight
Selection.Insert Shift:=x1ToRight
Selection.Delete Shift:=x1ToLeft
Selection.Insert Shift:=x1ToRight

View 5 Replies View Related

Syntax Of Loops

Feb 2, 2008

I am trying to figure out what a past employee's macros do and how they do it. I would simply like to know what the followin syntax enables you to do:

While ActiveCell <> ""


While ActiveCell. Offset(5) <> ""

View 3 Replies View Related

How To Expand Dropdown List

Feb 20, 2013

I have a data validation list that has approx 40 items.When I select the cell with the drop down list - only 10 or so items appear . I then have to use the scroll bar on the side to look further in the list. Is there a way that more than 10 or so ( possibly all ) items appear in the drop down box when the cell is selected - or is there a way that one can scroll down using the mouse wheel. ( I have to use the scroll bar at the moment ).

View 2 Replies View Related

Copying Cells Using Loops

Mar 19, 2007

I'm trying to copy cells from one sheet to another. I know that if I know what cells I want then I can use something like this:

View 9 Replies View Related

Expand Selected Range

Nov 15, 2009

I need help please. Using a macro, I have selected the range C7:C12. Now I need to keep this selection and expand it 18 columns to the right. This would give me a selection of C7:U12.

The original range changes at various times. Some times it might be C7: C452 etc.

I know it's easy, but I can get the code to keep the selection.

View 6 Replies View Related

Using Loops To Find Data

Feb 4, 2010

I want to find some code that will search down a column until it finds one of a number of different words. when it finds one of the words it stops and deletes the row on which the word is contained. after deleting the data in the row, it continues searching down the column until it finds another of the words.

for example......see work sheet attached,

I want some code that will search down column B until it finds Sally or Robyn. As soon as it finds either of these names it stops and deletes all the data in that row and then continues searching down column B to find Sally or Robyn again........

Is using a loop the best way to go with this?

MOD: thread moved to parent Programming forum (VBA)

View 14 Replies View Related

Copyrights 2005-15 www.BigResource.com, All rights reserved