Tagged Questions
0
votes
1answer
27 views
Excel VBA - Work with Subgroup of Array
I have a 1-dimensional array with 1000 entries. I would like to loop through parts of this array and apply calculate an average on that subgroup. What I have done so far looks like this:
Temp ...
1
vote
2answers
32 views
Excel VBA: Error handling only works for one pass
I have searched many sources to try and fix my problem, however I have had no success. I am a beginner at VBA, so my code will seem very messy most likely. For the purpose of asking the question I ...
0
votes
0answers
55 views
Linking input and output ranges when using a loop
I'm new to VBA and need help writing a macro given the following
A. Enddate = .Cell(lRow, 7).Value.
B. AnnualDepr = ".Cell(lRow, 11).Value.
C. PartialYearDepr = "(.Cell(lRow, 11).Value) /12) * ...
0
votes
1answer
57 views
VBA Arrays: adding elements based on conditions
I would like to collect the results of a loop in an array. Ideally, I would keep the results of the first loop and compare it against the results of the second loop. If the results of the second loop ...
1
vote
1answer
65 views
Constructing an array with VBA that will contain the contents of each column in an Excel file
I am working with an excel file that contains 5 columns, each for a distinct element.
I tried to create a collection of Columns, where each element of that collection will contain the data from the ...
-4
votes
1answer
58 views
I need to loop through a specified number of rows and unspecified # of columns [closed]
I am trying to write vba code that cascades cell entry through columns. I need to enter an x in cells going down a column to row thirty one. All columns go to row thirty one and the # of columns is ...
0
votes
1answer
50 views
Optimise Autofilter Visible Dropdown Loop
I'm trying to optimise the code below;
With Range("A2:IW2")
For i = 1 To 8
.AutoFilter Field:=i, VisibleDropDown:=True
Next i
For i = 9 To 253
.AutoFilter Field:=i, ...
3
votes
1answer
123 views
how loop plots in excel vba macro
I am trying loop the scatter plot over columns using Excel VBA, but did get idea how to do it.
Here is a dummy data I produced by filling Y series with RAND() function and the figure shows a sample ...
0
votes
2answers
128 views
Vba excel. Multiple cell selection not range
I want to loop through every row and do some actions for multiple cells selected, e.g. K3,N3,Q3,T3,W3,Z3 next K4,N4,Q4... etc.
What am I doing wrong?
Sub Colors_test()
For counter = 3 To 110
...
0
votes
2answers
170 views
Loop With Solver VBA
Hi I have the following code which runs a single optimisation through solver which I would like to run in a loop. the single run code is:
Sub Macro4
SolverReset
SolverOk SetCell:="$D$36", ...
3
votes
3answers
110 views
Delete Row Loop Optimization VBA
The code below was written as part of a random sample generator. Based on the total number of occurences, it calculates the sample size and reduces the population to the sample size. Right now I'm ...
2
votes
1answer
181 views
VBA loop conditional stops being evaluated after arbitrary number of lines
Here is my code. The code itself seems to work but for some reason the conditional statement stops after line 32645. I tried switching all variables to Long, didn't help.
Also, the code works if I ...
0
votes
2answers
116 views
Conditional Loop, Values not adding to array
I am trying to read in a single value for WC(1). I would then like to use the initial value of WC(j) in a conditional loop. I get the first value of WC(j) to run smoothly (it meets the first condition ...
0
votes
1answer
107 views
Excel Conditional Formatting Loop
I have this code:
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=IF($B5=""ARC"",1,0)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With ...
0
votes
1answer
141 views
VBA how to pass named range Name into a formula rather than a cell content
I have 3 ranges, "AA", "AB", and "AC".
The names of these ranges are on sheet 1 in column A.. so....
Cell A1 contains two letters "AA"
Cell A2 contains AB
Cell A3 contains AC
I need a formula to ...
0
votes
0answers
307 views
VBA Cut and Paste New Sheet based on Column Value
There are multiple inquiries on this subject, but I can't seem to find one that addresses the biggest one of my problems.
I've used the below script somebody helped develop that takes the value in ...
0
votes
1answer
428 views
VBA: looping through a list of named ranges and pasting them to another sheet based on an address reference
I am making some VBA code to help me do the following:
Paste a list of all named ranges
Loop through the list and copy/select ranges based on the list
Each selection will be pasted on another sheet ...
0
votes
1answer
1k views
VBA Excel Store Range as Array, extract cell values for formula. Offset for other variables
I'm a bit new at this. How would I take the column and put the cell data of which is an integer and go through all values in that range to put it into a function to output the result into another ...
0
votes
1answer
77 views
Naming multiple ranges using blank cells in column A to define the range size
Firstly I'm new to this so please forgive me if I seem ignorant or if my request is poorly formatted.
I have a spreadsheet that has been exported from an ERP system. Column A contains a part number ...
0
votes
1answer
206 views
VBA Excel Loop Multiple Observations Per Subject/Record
I have a question regarding copying cells from one sheet to another using VBA.
Question Background:
Sheet1 of an excel spreadsheet contains headers and a number of test observations from multiple ...
0
votes
1answer
418 views
Copy and Paste Loop based on Cell value
Created a macro below thanks to help from another that works.
Basically, it takes the value of the cell in column A and, if a sheet doesn't exist with that cells name, creates it. Then it pastes all ...
0
votes
3answers
527 views
VBA code takes very long time to execute
The following VBA code takes very long time to execute. I ran it 25 minutes ago for 48,000 rows and it's still running. How can I shorten the execution time?
Sub delrows()
Dim r, RowCount As Long
r ...
0
votes
1answer
269 views
Type Mismatch error when running VBA code to delete rows based on specific criteria
I'm trying to delete some rows in an Excel sheet based on some specific criteria. At some point, it gives the following Type Mismatch error:
As far as I understand from the partially created sheet, ...
1
vote
2answers
38 views
Trying to Create a Loop That will Start and End on Specific Sheets
I am new to VBA. I am trying to create a set of code that will allow me to start and stop a loop in between a set of worksheets.
Background: I have a file that I use to update several important ...
0
votes
1answer
1k views
VBA Loop through multiple folders [duplicate]
Possible Duplicate:
get list of subdirs in vba
I'm trying to apply the following code, which applies to running this VBA loop through all files in a folder, to make it run through all ...
-2
votes
1answer
69 views
Using True and False to select items to print
I have a workbook that contains rows of information that needs to printed to a seperate worksheet in excel. I am trying to utilize a checkbox to indicate which items need to print and which items ...
1
vote
1answer
948 views
Excel VBA find/replace loop - really new at VBA
I need to add a section within an existing macro that takes a cell's address and looks for that address (as a string?) from the values within a range of cells elsewhere on the sheet - then offsets one ...
0
votes
2answers
163 views
Loop simple function through all worksheets
I'm attempting to create a macro which performs the following on every Worksheet in a Workbook.
Range("U10").Select
FormulaR1C1 = "=R3C2"
Range("U10").Select
Selection.AutoFill ...
1
vote
2answers
2k views
Excel VBA : Looping a simple copy of a worksheet over multiple workbooks in a folder
I'm attempting to apply a macro that would copy and paste one specific worksheet (call the title of that worksheet "x") from one workBOOK ("x1") , onto a master workBOOK (call that workBOOK ...
0
votes
1answer
1k views
Excel VBA: Chart-making macro that will loop through unique name groups and create corresponding charts?
Alright, I've been racking my brain, reading up excel programming for dummies, and looking all over the place but I'm stressing over this little problem I have here. I'm completely new to vba ...
3
votes
1answer
119 views
Why does this IF statement not require an End IF
I am using the following snapshot of code to loop through files in a folder, it has a simple If to check if there are files in the folder then exits if there aren't. I've realised it does not require ...
3
votes
1answer
892 views
Excel Macro: How to loop a chart making macro through a specific column every time the name in that column changes
Alright so my goal is to create a chart making macro since I have about 90-some different Station name; and Each station needs it's own chart.
The multiple series I would like to use are my estimated ...
1
vote
4answers
9k views
Vba macro to copy row from table if value in table meets condition
i'm trying to make a macro which:
goes through a table
looks if value in column B of that table has a certain value
if it has, copy that row to a range in an other worksheet
The result is similar ...
1
vote
1answer
236 views
VBA checking range in different collumns
i've got xls file with multiple sheets and multiple columns with data (in blocks of 6 columns) in them. I have to copy this data to the last sheet, each under the last one.
In other words, it now ...
0
votes
2answers
6k views
Excel VBA: Looping Though Cells In ActiveSheet
I'm trying to loop through a specified number of cells (defined by width and height), but I'm running into problems here. It keeps stalling on me, and then gets upset about:
If .Cells(11 + row, ...
0
votes
1answer
84 views
I need some help on designing a program that will perform a minimization using VBA Excel
How do I use Excel VBA to find the minimum value of an equation?
For example, if I have the equation y = 2x^2 + 14, and I want to make a loop that will slowly increase/decrease the value of x until ...
0
votes
2answers
355 views
VBA nested Loop flow control
I will be brief and stick to what I know. This code for the most part works as it should. The only issue is in the iteration of the x and z loop. these to loops should set the range and yLABEL for the ...
1
vote
0answers
372 views
Importing a single row of excel data from
I am looking to do a slight variation on the below question and code.
Overview:
I have a folder full of "Request Forms" in Excel from individual customers which will grow in number.
I have a ...
0
votes
1answer
4k views
Copy multiple rows from many sheets to one sheet
I receive a workbook daily that lists 50 rows of information per page on a variable number of pages depending on how many rows there are total.
How can I copy the 50 rows from each page onto one ...
3
votes
2answers
30k views
Excel VBA: Loop through cells and copy values to another workbook
I already spent hours on this problem, but I didn't succeed in finding a working solution.
Here is my problem description:
I want to loop through a certain range of cells in one workbook and copy ...
2
votes
1answer
3k views
exit a nested loop in excel
i have a loop in a macro i'm writing of the following structure:
there are two worksheets in this book. raw data (hence the endpointData variable) and a G/L (General ledger) sheet (hence the ...
3
votes
2answers
455 views
Specify Additional Directory to Loop Through Excel/VBA
I am looping through a set of directories using a File System Object, and I want to specify an additional directory to loop through. For example, I currently have:
Sub test()
Set objFSO = ...
2
votes
2answers
2k views
Looping Word Match Function in Excel VBA
I have a list of keywords and want to see if one cell contains any one of these words. For example if my list of keywords is (Cat, Dog, Turtle) the function would return MATCH if it was looking ...
5
votes
2answers
2k views
VBA-Loop with some worksheets
I am a beginner and I would like to do a loop in all the worksheets of my excel file, except the first one. However the code below only works on the second one. Could you please explain me what is ...
1
vote
2answers
2k views
Looping through range using VBA in Excel
I have a block of code that takes way too long to process for some files. Smaller files (fewer lines of data) work fine, but once I get to about 150-300, it starts to get slow, (sometimes I think the ...
1
vote
1answer
7k views
VBA EXCEL Multiple Nested FOR Loops that Set two variable for expression
Ok so I’ve done a good deal of searching found some and played and little. I cannot seem to get these loops to work fully I can get on part or another but not the whole. As is the first loop works ...
1
vote
1answer
67 views
How to adapt a loop's structure to a user's preference?
I'm using a loop to fill a collection. There are a few properties for each item of the collection, but some of these properties are optional. The user is prompted to choose which properties will be ...
0
votes
1answer
1k views
VBA whats the best way to Increment in loop
What would be a good way to increment each of my ranges for example I need x to copy Range B11:to G20 and paste it to C10 for the second loop. Each Variable has different increments.
Im using excel ...
0
votes
2answers
79 views
excel files loop
In my excel sheet I'm using formulas which referring to external sheets.
Instead of manually changing the value in cell E7 (where I insert name of external sheet), I want to write an macro to open all ...
2
votes
1answer
561 views
Select range using specific criteria within a contiguous column of data
I want to have VBA select a Range, covering a constant number of columns but differing numbers of rows from a contiguous data set in excel, capturing only the rows that contain matching timestamps (in ...