for each loop

  1. F

    Like Function in VBA/Macros

    Hello, i am tring to run a "For Each" Loop in excel with the condition that if cells in selecton trends ("Like") with another range. Range("A:A").Select For Each MyCell In Selection If Mycell.value Like Range("B:B") Now I am not sure if I can run Like function against a range ... it works if...
  2. Prevost

    Find non-blank cells in range without for loop

    Hey There. I have a general question. I find myself using the 'For Each' loop when going through either user selected ranges or pre-defined ranges to find cells that have specific values, are blank, or are non-blank. Is there a more efficient way to accomplish this? For example, I have a range...
  3. H

    Making Groups in 'For Each' loop

    I am compiling a list of BOMs. It will first list the assembly name, and then list all of it's components in the rows underneath. The assemblies name and fields pulled with it must be bold. The list of components underneath it must be group together, so i can collapse all the groups and just...
  4. S

    VBA: Looped code doesn't populate correct cells on certain sheets

    Greetings, The code below works correctly on certain sheets. The code is supposed to calculate the percent change from 1990 to 2012 and from 2005 to 2012, and put the calculations on the 4th and 5th row from the last non-empty row, respectively. All the sheets are identical except for 3. The...
  5. O

    Copy Paste without changing sheets

    Hi all... first post here. I tried looking for this in various Copy/Paste threads but couldn't find exactly what I needed... The following code works fine except for the fact that it takes a long time (2 to 3 secs in 5 lines) for this for loop to run and I'd like it to do the pasting in the...
  6. M

    Macro to search for blanks in a column and enter a static value for each blank

    Hello, I typically don't post questions because I can typically find my answer; however, I am having a very difficult time applying what I have found to my situation. I am new to VBA and have been using the record function to learn the basics of VBA Macros. So please accept my apology if this...
  7. C

    For Each cell In rng - not recognising cell value - ?

    Hi there, I cannot seem to get the Excel vba to read the text/string within a cell, to give a specified result, it just ends up going to the 'Case Else' statement? Code: Sub StandardLifeInsuranceInvestmentBondNewStyleXX() Application.ScreenUpdating = False Dim rng As Range Dim cell As Range...
  8. R

    For Each Unique Value ... Next

    I have a list around 1,000 cells long in column A with about 100 unique values. I need to set up a For ... Next loop but only want the loop to run once per unique value. I've thought of copying the values to a temporary column and removing duplicates, then running the loop and deleting the...
  9. C

    Select Case Statement in For Each Loop

    Hi there, will do my best to be brief: I have the code below to loop through cells in column A and then place a result into column B based upon the value in column A. I also want the value of the cell to be put to Upper Case only for the purposes of comparison, i.e. I do not need it changed in...
  10. T

    Iterating through an Array

    Hi, I have the following code: Function Extract(Products As String) As String Dim softProdArray() As String Dim out As String Dim prod As Variant softProdArray = Split(Products, Chr(10)) For Each prod In softProdArray If InStr(prod, "ORACLE") > 0 Or InStr(prod, "SYBASE") > 0 Or...
  11. F

    Help - Combine Sheet in all file

    Hi All New to the forum, please be gentle with me... Please see the macro below I found this combine macro found on the internet, it works perfectly on its own The Macro combines all the files in a particular folder and saves it as one However, I need it to combine the files in 89 separate...
  12. J

    Next usage in For Each Loop

    Dim oFile As Object, oFolder As Object Set oFolder = CreateObject("scripting.filesystemobject").GetFolder("C:\") For Each oFile In oFolder.Files If InStr(1, oFile.Name, ".pdf", vbTextCompare) Then MsgBox oFile.Path Else: Next oFile ... Next oFile End Sub Naturally the above will throw up...
  13. S

    For Each Loop...... Thoughs?

    Hello, I am currently struggling to get my first loop working. When i run it i get "Run-time error '1004': Application-defined or object-defined error". This is the code that I am currently trying to run: Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim oneAddresses As...
  14. T

    For Each Worksheet and For Each Cell

    Hi all, appreciate any help you can offer On a regular basis I receive a file with multiple worksheets, each with a group of cells that I want to perform a simple conversion. Although I haven't used a For Each loop before, I get the idea and thought this would be the best way to go. The code...
  15. R

    VBA for each loops

    I am trying to write a sub that compares the values from one range to the values in another range, and to perform certain functions if it finds a match. However, if the corresponding value is "N/A" I want the loop to automatically skip to the next checked value "a" . I do not know how to skip to...

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