for loop

  1. B

    How to record values in a For loop to be displayed by a message box after the loop is done

    Hi, I'm not sure how to progressively add values that meet a certain condition into a message box, but I think it's possible. a = integer a = 1 For a = 1 To 21 If ActiveCell.Offset(a, 15).Value = ActiveCell.Offset(1, 11).Value Then MsgBox ("This " &...
  2. B

    Add multiple TextBox data to sheet

    Hi, I want to add data from multiple textboxes to a sheet that. The form has multiple lines containing product data, like part, description, location, qty It also has a textbox where you can enter the qty you need and txtQtyAdd If the txtQtyAdd textbox contains a value it should copy the data...
  3. K

    For and for each loops

    I need help with this assignment for my excel/VBA class. I have been struggling with VBA 1. manually enter 1 to 100 in cells A1 to A100 2. write a for loop that makes use of the offset property to sum the numbers in every 5th cell starting with A3. The loop should stop once A100 has been...
  4. E

    Loop Through Pivot Tables And Remove Same Values

    Hi All, I am trying to loop through all pivot tables in a sheet and remove all values fields in them which have the same name: "Total Net Spend" and "% Split". I am trying the below code but it will only work on the first pivot and won't loop through all of them. How do I edit the code so...
  5. F

    Collection subscript error 9 used in a For/If loop

    Hey guys, I'm trying to manipulate 2 collections in my code. After comparing the difference between 2 values I need to remove those that are less than a set number. However, I run into a "Run-time error '9': Subscript out of range." I've pulled out the relevant sections from my main code to...
  6. D

    Nested Loops & IF Statements

    Hey guys, I have the following code and I keep getting a "next without for" error, although I can't seem to debug it! I've tried to strip the code to its raw "For" and "If" statements. If existing_sheet = 1 Then For x = i + 1 To i + 100 If Worksheets("Master Fee Table").Cells(x...
  7. M

    Excel VBA Worksheet Calculate running slowly

    Hello all, My question pertains to the Worksheet_Calculate VBA sub. I have the code below that I wish to execute every time a cell is "confirmed" within the worksheet. Basically, I have the table range that spans columns A:I, with various field headers. Column A has numbers that either...
  8. J

    Understanding IF loops.

    Hello again, I am just starting VBA and trying to practice loops. Can you please help me understand why this code works: For startingnumber = 1 To endingnumber If startingnumber = 1 Or startingnumber = 3 Or startingnumber = 5 Or startingnumber = 7 Or startingnumber = 9 Then...
  9. S

    For Loop and array allocation problem VBA

    Hello members, I am re coding a code from one C based language to VBA. Can you please help me to sort the problem or rectify any mistakes? Here is original code: PlanetDeg[1] = DMoon; PlanetDeg[2] = DSun; PlanetDeg[3] = DMars; PlanetDeg[4] = DMercury; PlanetDeg[5] = DJupiter...
  10. andrewb90

    Help with a For Loop

    Hello All, I'm struggling with getting this right, so hopefully somebody out there can assist me. I am trying to take the range E89:R106 And with each row, If the Value in Column A of that row is "TRUE", nothing happens, otherwise If FALSE, E:R in that row will have the contents cleared...
  11. P

    Macro code for filling up data with respect to count of Next column

    Sample: A B C D E 1 ani sq 250 33 450 2 111 22 222 3 444 44 222 4 123 12 899 5 122 34 113 Now i want to make a code that fills same data in A1 and B1 up to A5 and B5, If i have data in C,D,E column upto 100 count means...
  12. P

    VBA Iteration not calling different values?

    I am writing a function to calculate the standard error of the estimate of a linear regression (I understand excel already has this), but I am doing it so that I can give it the linear equation that I want to be considered, rather than the function calculating it itself as the STEYX built-in...
  13. S

    Help needed on macro for project!

    Hi, I am trying to write a macro to assign a set new of serial number to each row. For example, each row will be given a number (in sequence) after every 8 rows and when there are no other numbers below it, the code will go back up again to continue the pattern again. Any help on this will be...
  14. S

    Colour Coding Cells; For Loop Matching 2 Arrays

    Hi All, I'm in need of a bit of assistance, I'm sure it's a very simple tweak but I'm struggling to get my VBA code to do what I want... I'm trying to see if a number is present on another sheet, and if so colour it in. So I'm trying to save two arrays, one a 'stocklist' (built) and...
  15. andrewb90

    For Loop Help?

    Hey there, I have been trying to do a for loop to change my currently working but long code. Basically I have 30 rows and each row sends a unique message. And currently I am using this code: Sub FOH1() Dim r As Range, c As Range Dim sTo As String, ppdf As String, pdf As String, p As...
  16. J

    Named Range.clearcontents issue

    Hello MR.EXCEL users, Its been a little while, I have been smooth sailing let me tell you! Ran into a little problem today... The following code is working perfectly, but is obviously cumbersome if the range gets too big. Dim job As Range For Each rng In ws.Names If InStr(1, rng.Name...
  17. J

    Idex Match in For Loop to alter Column data is taken from

    Good Morning, I dont understand why this peice of code will not work for 'i'. I can loop the column very easily. But, with or without the column for loop, the 'i' for loop will not work. For Col = 1 To 7 For i = 1 To 7 With Application.WorksheetFunction...
  18. M

    VBA Loop until certain value is entered (to infinity) with For Loop

    Hi there, Trying to come up with a code that will loop an infinite number of times until the user enters a specific range of values. I can do it using 'Do While' or 'Do Until' loops but the assignment specifically mentions 'For Loop'. Please help. Thanks! Here is what I have now: Option...
  19. Y

    Display All Permutations of a List Without Repeating Values

    Hi Everyone, I've been trying to get this to work this out for a while but am starting to struggle and am running out of time! I'm trying to optimise a running order for a show and am looking to generate all possible permutations of a possible running order with 28 acts. Below is an example of...
  20. A

    VBA Speed question - one huge array (400000 rows) vs reading every k-th row

    Hello, I was wondering, is it more efficient to: grab huge range A1:M400,000 into an Array 1, create a new subArray 1 to use, from Array 1 in VB (every 12th row) OR loop through range with "i = i + 11" every time, creating a subArray 1 this way? I'm thinking it has to be 1 but do we know...

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top