for next loop

  1. B

    VBA For Next Loop runs slower after first time through

    This one is throwing me for a loop (apologies for the pun...please still help me!). I'm confused about this one. Here's what the macro does, high level. Opens a template workbook. Saves a copy of the template workbook as a temp file. Loops through a list of other "original" workbooks: One at...
  2. R

    Run-time error '1004' Method 'Range' of object '_Global' failed

    Can't quite see/figure out what I've done wrong (I don't know what I don't know :confused: ). I'm getting: Run-time error '1004' Method 'Range' of object '_Global' failed I've tracked the error down (I think) to the FOR-NEXT loops in the following snippet of code (edited for...
  3. O

    Using a Loop to Assign and Complain Variables in an Array

    Hey, I'm writing a program in vba for work that I want to take the data from each row in columns a and b, then combine that information into a string variable that's part of an array, then check to see whether that same combination appears again. At the moment I'm having trouble with creating...
  4. P

    Question on For Next Loop speed

    I've been using for next loops to check a range of cells on each row using if statements with each if statement referring to a specific column cell on that row (ie: if cells(RowNum, 2).value = "No" Then cnReports.cells(NextRow, 5).value = "user entered No", And Each column on that row i check...
  5. M

    VBA For Next Loop

    Hi, I am trying to update a report with a list of cost centres and copy each report created to a new tab. The sheets in my workbook are called: CC List CC REP The steps I am trying to code into a for next loop are as follows: update a specific cell (criteria key for a sum if) on CC...
  6. S

    Populate CheckBox Captions with loop

    Hello all, I have a userform that will allow the user to say what data they want to print from a table. What I am having issue is that I can't figure out how to use the looping integer with the userform's checkboxes. So this is just the logic of what I'd like to accomplish, obviously it does...
  7. P

    UnMerge Cells inside a For... Next Loop

    Hi group, I'm having some problems with a For/Next loop that has a "UnMerge" inside it. After the copy and paste is completed, the routine stops and doesn't complete the "Next" portion of the loop. Are they any thoughts as to why? What should I do to fix this? Here is the code I'm using...
  8. Kelinky_Sama

    Simplifying Variable Declarations with Other Variables

    I'm rather new to Excel macros, so please be patient if I'm asking for something that should be rather simple. What I'm attempting to do is recreate an RPG "inventory" of sorts with a UserForm in Excel VBA. So far, the way I've managed this has been by placing a ToggleButton underneath a...
  9. J

    Compile error "Next without For"

    Hi there, When I run this code I get the compile error "next without for" and I can't figure out why Sub Find_Class_A1_then_Hide() Application.ScreenUpdating = False Dim r, Lastrow, cLastrow, tRow As Long Lastrow = Cells(Rows.Count, "A").End(xlUp).Row For r = 1 To Lastrow cLastrow = Cells(r...
  10. J

    I am getting the "next without for", but it is there???

    Hello - in the following code it is suppose to take the values in column B on activesheet one at a time and perform a search of that value on sheet (SMs), returning it and the values of neighboring cells back to active sheet. I can not get it to work as is...right now I am getting the "next...
  11. A

    Need to make the .find loop more efficient

    Hello everyone, I've put together a code for below steps. However, I feel the procedure is too basic and there might be more efficient ways of doing the same. The present code is taking quite long, particularly the .find loop. I would really appreciate any help you can provide. Procedure...
  12. M

    Default Skipping an i, or multiple i's in a Loop - please help

    I am writing some code to generate multiple pivot tables in excel. My spreadsheet is set up with survey responses to a variety of questions with the question number across the top, and the survey responses below in the column. My problem relates to questions 8, 10, and 13. As you can see in my...
  13. bfreescott

    entirecolumn delete is throwing off my for each loop

    This snippet of my code is behaving oddly (at least to me) because when the column of range c is deleted, c then becomes c plus one, instead of next c. I hope that is clear enough, but just in case it's not, let me give an example: When looping through a row of ranges on row 11, if c is in...
  14. G

    Improve VBA function run-time - replace For/Next Loop

    I have the following code which operates as it should, taking a text string in the adjacent cell and converting it to a formula and applying it to a few other referenced cells. I currently only have about 20 rows of data but I anticipate having nearly 1,000. The run-time is already too...
  15. M

    VBA - struggling to calc and write StDev data into an array with a For Next loop

    I have made several attempts, this is the latest iteration. It shouldn't produce meaningful output until the minimum periods have been looped thru (volstperiod = 10). --PctChg1() is an array which holds percent change data from i=2 to i = 2541... declared as variant --volstperiod = 10...
  16. A

    Nested for next loops not iterating the outside loop.

    I have a range of data from A2:A34 with various names in it that I need to copy to the range E9:E14. I only need to copy and paste unique names (I don't need a double of the same name). I am pretty sure using a nested For Next loop is the way to go but I'm having trouble getting the outer loop...
  17. B

    Categorizing Column Values Using Multiple Criteria

    Hello all, I am working with an aging report where data is formatted in column. In the last column I would like to assign a value based on criteria from the adjacent columns (ex: If balance > $10,000 then value = "Hold"). My idea was that I would asign variable to the column, start a for next...
  18. K

    Skip Worksheets in For Next Loop

    Good morning experts! I'm trying to loop through worksheets as follows: If ws.Name <> "DataTable" And ws.Name <> "Summary" Then ws.Activate code to do some copy/paste stuff .... Next ws Try as I may, I can't get the code to skip the worksheets named "DataTable" and "Summary". Based on other...
  19. T

    How to declare a Public Array in Declarations

    I am trying to declale a public array so I can use the dataset throughout the module for quite a few functions. At the moment I am creating the same array for each function and then iterating through the array to calculate the function, so rather than doing this many times I am trying to speed...
  20. C

    Probably the Easiest Question to Answer...

    So, I feel a little dumb asking this, but I've tried to work on it and figure it out all day to no avail, and I figure this is the quickest way to get an answer... I wrote this code on a machine running excel 2003 and everything seemed to work fine, but I brought it to my iMac at home running...

Some videos you may like

This Week's Hot Topics

Top