for loop

  1. D

    Outlook VBA to list the text strings of all folders and subfolders i.e., beyond two levels

    Hi Folks, The code below is listing the Outlook path for all my Outlook Folders but only two levels deep. e.g., \\Douglas.Markham@thecompany.com\Inbox\01) doug's jobs\completed jobs I've tried to nest a third For loop into the code to pull out the next level of folder e.g...
  2. N

    Runtime 1004 error with For Loop

    The code below is throwing me a runtime 1004 error when I try to run the macro: Denoted with "'THIS IS WHERE THE ERROR OCCURS" I suspect this is because I am using checkboxes in the "Deliverables" worksheet to start the For, and writing content to the "ReviewContent" worksheet after the If...
  3. D

    How do I change the selection in a For loop?

    I'm trying to put a string together, compiling the words in A1:C8, by column. The output for the first column output is A10, the output for the second column is B10 etc. and I want the selection to change each time too so that it only includes column A in the A10 output, column B in the B10...
  4. D

    How do I change the output destination in a For loop

    I'm currently trying to put a string of cells together in a and complete it across several columns but I can't figure out how to change the destination for the output each time Sub test() Dim x x = 7 For x = 7 To 595 Dim rng As Range Dim i As String For Each rng In Selection i = i & rng Next...
  5. I

    Copy columns based on header and array

    Hello, I have data in Sheet1 that I'd like to copy into Sheet2 based on the header. I'd like to create some kind of text array that I can update in the code to include new columns if they become relevant. I'd like the relevant headers array to be something like sWords = {"Date", "Qty"...
  6. V

    Functionality of UBound in For loop

    What is the functionality of UBound in for loop for the below code. x = wsPlan.Range("A1").CurrentRegion.Value Set Plan = CreateObject("Scripting.Dictionary") For i = 3 To UBound(x, 1) For j = 2 To UBound(x, 2) Plan.Item(x(1, j) & x(2, j) & x(i, 1)) = x(i, j) Next j Next i
  7. G

    Repeated cells in same column VBA

    I am struggling to create a simple loop that will allow me to repeat a cell value down a column for a number of my choosing. I want to turn this: A1 A2 A3 Into this ("2", for example): A1 A1 A2 A2 A3 A3 Anything helps! Thank you.
  8. M

    Problem changing For Loop Maximum inside the loop

    Consider the following code: Last = 10 For I = 1 To Last Last = Last + 1 Next I At the end of the code you find I = 11 and Last = 21. The implication of this is that once you set the Maximum for the loop, you can't change it. So you have to use a Do While loop explicitly...
  9. A

    For Loop with data formatted as Time (hh:mm:ss)

    Hi everyone, I'm trying to create a for loop that iterates through each row in Column M. The data in this column is formatted as a time (Hours:Minutes:Seconds), I would like to flag any data (by highlighting the cell in red) greater than or equal to 7 minutes (00:07:00). The code I have now...
  10. B

    for loop using variable

    I am trying to use a variable to determine how many times to go thru a loop. The code that I am trying to get to work is shown below. If I use 'For S1 = 1 to 2", I go inside my loop 2 times. If I use 'For S1 = 1 to NumofTimes', I do not get inside my loop. The Msgboxes show a value of 1 and a...
  11. A

    VBA: Multiple if conditions with loop

    Dear All, I am writing a macro where i have multiple conditions for getting the data and i am stuck here as it is giving only single output that is "0-1 days"... Please help below is my code : Lastrow1 = Sheets("Rawdata").Range("A" & Rows.Count).End(xlUp).Row For A = 2 To Lastrow1...
  12. O

    Comparing Dynamically Assigned Variables In An Array

    Hello, I am writing a program that combines and compares the values in columns 1 and 2 using an array, then changes the color of the row those values appear it if it show up more than once in the spreadsheet. I know there is an easier way to do this with formulas, but the person I am making...
  13. S

    Current Macro not Looping through both variables.

    Hello guys! I have a current project where i am trying to get a macro to set E to A depending on whether or not the value in the previous row is a date. If it is i want it to simply copy down. But if the value before isnt a date i want it to change to copy and pasting the text value . Right...
  14. G

    Looping Through Select Cases

    Hello All, I have a independent combobox and a dependent combobox, the dependent combobox depends on the information provided in the first independent combobox. I know there is the select case to make fill the dependent combobox. Here is a brief overview what my code does. I have two...
  15. M

    Make For Loop Show Error Message

    Hi everyone, I can't figure out how to make my simple for loop code show an error message when it no longer finds any cell(s) that meet the criteria. The criteria is that the first cell must match "K1110" while 4 cells to it's right must be blank. Please note that this code works fine. But...
  16. C

    Loop through Multiple Worksheets, with autofilter, for different Criteria

    I've searched several forums over the last few days and have been unable to find exactly what I'm trying to do. Apologies if I missed it somewhere in this forum. Currently, I have a functioning macro that will autofilter each worksheet for the specified values from the main "input" worksheet...
  17. C

    VBA for dynamic conditional formatting.

    Hi, I need to reference a cell in Column A and B on the Active row for a conditional formatting command and am having trouble. It isn't the most glorious bit of code but it works with the exception that its hard coded to reference A2 and B2. Rather I need A and ActiveCell.row or...
  18. V

    Code explanation

    FolderLoc = FolderLoc & "" & "Jan" & ". " & Year 'Inside the Folderloc there are ten's of file and each and every files has atleast three more files in it. Set FSobj = CreateObject("Scripting.FileSystemObject") Set ProjectsFolderObj = FSobj.GetFolder(FolderLoc) For Each BCFolderObj In...
  19. J

    Loop to Ignore Hidden Rows

    Hello, I have a worksheet that's split into groups of data with a heading at the top of each. For instance, row 3 has a heading, then 4-9 have data that goes with it, then row 10 has another heading, and so on. Some of the rows of data are hidden using VBA based on certain values, leaving the...
  20. W

    If False Do Nothing

    How do you do Friends, I have a large data set and I would like to search for a keyword and update the cell 5 columns over from it. This is what I have so far: Sub Find_and_Write() Dim X As Variant, F As Range X = Application.InputBox("Enter Value") If TypeName(X) = "Boolean" Then Exit Sub...

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top