Running A Loop On A Few Columns Simultaneously

Feb 13, 2010

I am trying to run a loop on a few columns simultaneously, from the last row to the top (well, until the 2nd row).

So I have a few columns of data, A through I, and the number of rows they populate changes all the time.

So how would I run a loop that will check for the following:

If a certain row in Column F is greater than the previous row in column F by 1.5times, then in that same row, if number in Column B is greater than number in E, the code should put the the value of E in a new column, lets say M (in the same row)

I know that sounds very confusing, but is that even possible? I am playing with loops, and I can only do very simple loops where I define a range, like

View 14 Replies


ADVERTISEMENT

Prevent Custom Functions From Running Simultaneously?

Jul 31, 2014

I have this excel file with some functions inside a Pivot Table, which use a year value as filter (the value comes from a report filter field) and data from a different spreadsheet to calculate a percentile value ... I created custom functions to replace the excel functions, passing the values as parameters.. The problem is now that when we refresh the connection (Refresh All button under DATA tab) the cells that contain the values returned by the custom function lose those values (go blank) In order to get the values I need to select the filter value again, while when I was using the normal PERCENTILE function the values would always refresh normally

Now... I think the problem might be related to the fact that the spreadsheet in question calls 5 different custom functions at the same time.... and, those 5 function call another at least two more helper functions... so, maybe this recurrence in calling the functions is causing the thing to break up

Is there a way I can prevent this from happening? Maybe put some flag or something that will cause the functions to be executed one by one, and not all at the same time?

View 2 Replies View Related

Sort Two Columns Simultaneously

Apr 8, 2009

I'm trying to sort selected rows by two columns, but simultaneously instead of sorting by "Column A and THEN Column B". In my case, this is numerical data where there is ONLY data in one column or the other, never both.

For example:
5 _
10 _
_ 1
_ 6
_ 4

Should sort to:
_ 1
_ 4
5 _
_ 6
10 _

View 9 Replies View Related

Freezing Several Columns And Rows Simultaneously

Mar 1, 2012

freezing columns and rows it does not seem possible to freeze MULTIPLE rows AND MULTIPLE columns simultaneously in the same spreadsheet.

In my spreadsheet I would like to freeze columns A, B, C as well as rows 1 - 8.

View 5 Replies View Related

Automatically Sort Columns Simultaneously

Apr 21, 2008

there are two colums, one for product name (unique names) and other one is for their prices (may be same for more then one product). I want to arrange these columns by the their price vlaues in assesnding/desending order and to have their unique corresponding product names in respective columns. Provide me any solution, probably using any excel formulas. presently i have tried this using Large and Vlookup funstions...but it fails.. when there are same price is available for two product names, then it takes only first one. I WANT TO GET THIS DONE AUTOMATICALLY, AS THIS IS TO BE POPULATED ON SOME OTHER SHEET AS A PARETO. waiting for your vlauable responces ASAP.

View 2 Replies View Related

Excel 2010 :: Sort Multiple Columns Simultaneously?

Jan 3, 2012

I am trying to sort each "Pct" column in descending order. Of course, I can do this manually, but I have over 100 to do, so I'd like to know how I can automate this (of course, the two columns to the left of "Pct" must move along with it).

delete
EFGHIJKLMNOPQ8BallFrqPct
BallFrqPct

[Code]....

View 2 Replies View Related

Nested Loop. Inner Loop Not Running

Nov 30, 2006

i have a problem with a nested loop:

it seems like the first instance of the code is running the way i want it to run, but when it starts with the second instance, it does the first search and copy, but it seems like the nested loop is being ignored.

am i doing something wrong?

dan
==========================================================
Thanks to Aaron Blood for the find_range function. i also poached the lastrow function from somewhere on ozgrid, but I cant remember the name of the poster.
==========================================================

Sub new2()

Dim Org_Area As Variant
Dim Item As Variant
Dim Copy_To1 As Variant
Dim Cell_Ref As Variant

r = 1 ..................

View 9 Replies View Related

For Next Loop Running Only One Time

Feb 22, 2014

Here is the image 1 after selecting one of element in listbox and then if I click delete material (commandbutton).

It has to delete the select material in sheet 2 and has to cut the element below and move to 1 row above as shown in figure 2.

At the same time it has to delete the entire respective column and remaining column has to be cut and place in column before in sheet 3 as shown in figure 3

For that I had wrote the program which is below

Private Sub CommandButton5_Click()
Dim i, j, k, m, n As Integer
i = ListBox1.ListIndex
j = Sheet2.Cells(1, 39).Value
k = j - i

[Code] ....

When I click the delete commandbutton5 the result is as shown in figure below

In sheet2

In sheet 3

For loop is running only one time after that it got terminated. If I split the 1st for loop and execute it.it is running nice what I meant to do. If I combine another for loop or If I add msgbox at top it misbehaving. I tried with do while loop also it also doing same thing.

View 1 Replies View Related

Running Loop Through Range Backwards?

Apr 11, 2014

I have below VBA code which output with adding , in between ranges. I am looking for way to running loop through range backwards.

[Code] ......

View 4 Replies View Related

Increase Efficiency When Running A Loop?

Apr 27, 2014

I run a rather simple loop (see below). But as it runs through A1 to A28000 it takes a lot of time. Is there a more efficient loop to operate this simple task?

View 9 Replies View Related

For Loop Not Running As Intended, Can't Find

Feb 17, 2010

I thought my code was working properly, but then I tried different numbers for myNum and I realize it's not. Here's the

View 5 Replies View Related

Loop And Displaying Results While Running?

Nov 11, 2011

What I am hoping to accomplish is have cells D3 & E3 display the numbers being cycled as it cycles through the loop statement. Current code is below.

Private Sub CommandButton1_Click()
Dim iRnd1 As Integer, iRnd2 As Integer, n As Variant, strJustice
Dim Counter 'tf

[Code].....

View 5 Replies View Related

To Copy And Paste Two Columns From A Worksheet To Another Worksheet Simultaneously

Dec 11, 2008

I would like to copy and paste two columns from a worksheet to another worksheet simultaneously. I would like to have a macro to do this function.

View 5 Replies View Related

Running Out Of Columns

Aug 9, 2008

I am building a massive model in Excel and I am running out of the columns....only 2 left out of the 256 allowed. I need a lot more columns so I am seriously considering moving to Excel 2007. I need your advice - do you think this move is adequate given that I can overcome this column limitation by continuing to build my model in the other sheets and cross- linking them? I will be using Solver or Evolver later on so I am concerned how these perform on Excel 2007. I am more concerned with the speed of excel 2007 when it comes to handling large workbooks.

View 9 Replies View Related

Macro Running With Columns From A To H

Jul 3, 2009

I have a macro running with columns from A to H and ''infinite'' rows
+conditionnal formating and one formula for the value in column D
I'd like to add one more condition, but I can't figure how...

*I'd like to add a step to the macro on sheet1 to automatically move a whole row (a to h) to sheet2 as soon as my equation in column D find a value = 0

after each row is transfered, i'd like to sort it in a descending order on sheet2 based on the number value in column A

what to add to get this to work

Private Sub WorkSheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub 'Only run if 1 cell is changed
If Target.Column 8 Then Exit Sub 'Only run if change is in Column "F"
If Target = Cells(Target.Row, "A") Then 'Check to see if entry matches column "A"
Else:
MsgBox "Invalid entry"
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
End If
Range(Cells(2, 1), Cells(Target.Row, 8)).Sort Key1:=Cells(2, 8), Order1:=xlDescending
End Sub

View 9 Replies View Related

Stop Functions Running While Show / Hide Columns

Nov 28, 2011

I have a couple of functions running in my workbook, and for no reason that I can see, when one of them runs during a simple macro I use to show/hide some columns, the worksheet vanishes. Is there a way to stop all functions running while I show/hide columns?

View 5 Replies View Related

Running Query To Access: Pulls Data From 2 Columns In A Table And Pastes It To The Spreadsheet

Jul 10, 2009

I have an Excel spreadsheet with a query to an Access table. The query pulls data from 2 columns in a table and pastes it to the spreadsheet. I am trying to update the VBA a little on one sheet and now I get the attached error whenever the code tries to run in Excel. Here is the code with the offending portion separated at the top.

View 2 Replies View Related

Loop Through Columns And Row?

Aug 16, 2014

I want to perform double_click event for combobox, but only for cells in certain columns and rows.

this is code :

[Code] ....

I have to loop through columns 6 to 67 with step 1, and rows 19 to 409 with step 5, but don't know how . I attached sample, coloured cells needs that double_click event.

Attached File : Loop_Column_Row.xls

View 12 Replies View Related

Loop To Run Through Columns

Apr 15, 2008

I am having some problems in setting up a macro that is intended to do the following

Run for every cell in a collumn a check if cell =2
If true then B1 is copied to that cell.
If false then nothing

This seems rather simple but the loop should go to collumn B, C, D, E, F,... until the last collumn.

Every time the collumn shfits the cell to be copied also shifts so is B1, C1, D1, E1, F1,...

View 14 Replies View Related

VBA - Loop Through Columns

May 12, 2011

I have a data set that I need to reorganise

Currently the data runs across the columns as:

COL A:C = Descriptions
ROW 1:1 = Week End dates
ROW 2:2 = Week Number
and D3:BC122 = Values
AccData

[code].....

What I need to do is create some VBA that will loop through E:BC moving the data in the column to under the data in Col C each time (and also A:C)

I can create loops that add 1 to row number but am stuck adding 1 to column in VBA.

View 7 Replies View Related

Loop On Two Columns?

Apr 5, 2013

I have two columns of data J2:K1000, I need loop through both columns at the same time and copy the data into cells into E1 and F2, then run through the remainder of the code. The code below I have adapted but cannot get it to work correctly.

HTML Code:

Sub Test()
Dim LastRowColJ, LastRowColK As Long
Sheets("Sheet1").Select
LastRowColJ = Range("J65536").End(xlUp).Row
For Each c In Worksheets("Sheet1").Range("J2:J" & LastRowColJ).Cells
Sheets("Sheet1").Range("E1").Value = c
For Each d In Worksheets("Sheet1").Range("K2:K" & LastRowColJ).Cells

[code]....

View 4 Replies View Related

Loop Columns

Aug 21, 2009

my worksheet has columns e1:il100 populated with data. what i am trying to do, is to insert a column to the right of column 'e', copy the contents of cell 'e1', to rows 3:100. then i want to cut e3:f100, and place it in the next available row in columns b:c, delete columns e:f, and then goto the next populated column, which i believe is now column e, and start over, until all columns have been moved to columns b:c.

View 9 Replies View Related

Loop Through Columns

May 3, 2007

I have a dataset with has 12 columns of data followed by 49 columns of values (one for each product) What I need (to be able to pivot it) is one column of values. I had written a quick for each loop but this doesnt work for colums:

Sub Adjust()
' Find last cell populated by data
Range("A65535").End(xlUp).Select
Last_Cell = ActiveCell.Row
'Rename a column heading
Range("M1").Value = "Partner"
Range("M2:M" & Last_Cell).ClearContents
'Loop through each column and copy data values
For Each Column In Range("N:BJ")
' Find first empty cell
Range("N65535").End(xlUp).Select
Start_Cell = ActiveCell.Row + 1.....................

View 2 Replies View Related

How To Create Loop Through Among Columns

Apr 30, 2012

i would like to create loop throug among columns, is xlup or xldown methods will make sensne ?

View 2 Replies View Related

Loop Through Columns And Sum Them At Bottom

Nov 17, 2008

I've been working on coding a summary sheet that pulls data from
worksheets in the active workbook.

I'm almost done, but am stumped at writing some code that will loop
through the columns that I have copied and total them. I recorded a
macro, but nothing happened when I ran it.

What I have now is this code snippet that I found which works
perfectly when I put my cursor in the active cell.
I am not sure how I should write it into my sub.

code that I found that works:

Set rng1 = ActiveCell.End(xlDown)
Set rng2 = rng1.End(xlUp)(2, 1)
rng1(3, 1).Formula = _
"=Sum(" & Range(rng2, rng1).Address(False, False) & ")"

I tried this:

For Each col In NewSh
ColNum = ColNum + 1
Range(RwNum, ColNum).Select

Set rng1 = ActiveCell.End(xlDown)
Set rng2 = rng1.End(xlUp)(2, 1)
rng1(3, 1).Formula = _
"=Sum(" & Range(rng2, rng1).Address(False, False) & ")"

Next col

View 9 Replies View Related

Loop Through All Columns Of A Worksheet

Nov 22, 2006

I am OK to set values to the third row of "Loop Folder" from a column in " T" but I haven't figured out how to capture the remaining 22 columns of this worksheet.

Workbooks("Loop Folder.xls").Sheets("Sheet1"). Range("A3").FormulaR1C1 = Workbooks("B .xls").Sheets(" T").Range("C5").FormulaR1C1

Workbooks("Loop Folder.xls").Sheets("Sheet1").Range("B3").FormulaR1C1 = Workbooks("B .xls").Sheets(" T").Range("C6").FormulaR1C1

Workbooks("Loop Folder.xls").Sheets("Sheet1").Range("C3").FormulaR1C1 = Workbooks("B .xls").Sheets(" T").Range("C16").FormulaR1C1.............

View 3 Replies View Related

Loop Through All Columns In All Sheets

Nov 28, 2006

I am trying to loop all columns in each of a number of sheets using current region.

It selects the current region OK but the column counter only shows 1 as the number of columns in any sheet.

The Cells(6,1) likely has something to do with it but I do not know any other way to point to the current region I need. I do not know in advance how many rows or columns I am starting with but each has the required Row 6.

For x = 1 To Sheets.Count

Sheets(x).Activate
Cells(6, 1).CurrentRegion.Select
Selection.CurrentRegion.Name = "Mydata"

'Loop all columns in sheet

For y = 1 To Range("MyData").End(xlToRight).Column
Cells(5, y).Select

Next y

Next x

View 6 Replies View Related

To Do More Than One Search Simultaneously

Oct 26, 2007

Is it possible to do more than one search simultaneously. Let me elaborate. I have a data of 40,000 students in DATA A and searches each student in DATA B which is also around 40,000 students. Instead of doing a For Next Statement, searching one student at a time, is it possible for it to search all the students simulatenosly because searching 40,000 students in a data base of 40,000 students takes FOREVER?

View 9 Replies View Related

Concatenate With Loop Through 2 Columns Of Information

May 28, 2014

I have a list of names with blank cells in Column A cell 2.

I want the programme to scroll through this column until it finds a name, when it does I want it to look in cell offset(1, 1), in this case B3 to see if there is a number. I want this number to be moved to offset (0, 1) AND any subsequent numbers below it until the next blank cell in that column (B).

In the attached image cell B2 will contain all numbers in cells B3:B9 with a / between them. Cell B10 will have number from B11 and B12 will have B13:B15. If there is no number it will just continue to the next name in column A. My rough code below delivered the first number only in the relevant cell and I'm not clever enough to get it right. It does not have to be super slick as it's for one time use.

I need numbers in column B cleared as they are concatenated into the single cell.

Spreadsheet.jpg

View 12 Replies View Related

Select Columns To Merge Within For Loop

Nov 18, 2011

My issue is I want to use a for loop to go through a spreadsheet. Within the for loop if a certain condition is true I want it to select all columns from A to AW and merge them together.

Example of what I have so far:

Sub MergeHeaders
dim i as Intger, LastRow as Integer
LastRow = Cells(Rows.Count, "CP").End(xlUp).Row
For i = 1 to LastRow
'Check if the leading character is a letter, not number
If Asc(Cells(i, "AP")) > 64 Then
'I want select from A to AW only for current row i, then merge
end If
next i
end sub

View 1 Replies View Related







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