for each loop

  1. N

    For Each, Next ws not looping, possible range reference issue

    Hello, I have this macro to unlock and highlight cells in a range that should apply to the same range in each sheet of the workbook. It works great on the active sheet but it isn't looping. I'm guessing it's an issue with the range reference from sheet to sheet but I can't seem to get it, any...
  2. B

    Loop through table row to create shape

    Hey, I bring another problem to you people. I have some VBA code to check the last row of a certain table and create a checkbox in that row, if there are none. Problem is, if a row is created in the midle of the table, no checkbox is created in this row, because it is only looking for the...
  3. G

    Delete worksheets not specified in an array

    Hi folks, I have a workbook with >50 worksheets that are "core" ones that never get deleted. On top of that my macros generate many other worksheets (dynamic # and not always same names) temporarily as I work with data. Before saving, I minimize the file size by deleting the temporary sheets...
  4. P

    Get the address of cell from a for each element

    I'm very new to using VBA. I keep receiving a run-time error when I try to get the address of the cell. Sub Supervisor() SuperRange = Range("D3:D4") For Each cell In SuperRange If cell Like "*.*" Then MsgBox cell.Address Else MsgBox "nope." End If Next End Sub
  5. M

    Type Mismatch Error (Error 13) in a SELECT/CASE Routine (Nested For Each Loop) for Conditional Formatting

    Hello, I am trying to define a VBA MAcro for Excel 2019. I have a reasonably big dataset in which every column (variable) has numbers with different scales and meanings. Would like to automate conditional formatting so to loop through each column in the range of interest, identify empty cells...
  6. J

    Loop through Field on Power Pivot Table

    I have a bit of script that I need some assistance with. The purpose of the script is to iterate over a Power Pivot table and for each item in the pivot, filter and export to a new file. However when I get to the line: 'pf.CurrentPage = pi.Value pf.CurrentPageName = pi.Value With...
  7. L

    For Each / Do Until Loop Hit a Wall :-(

    Hi everyone, so I've been working at this problem for a while and can't get the code to produce exactly what I need. I have a spreadsheet which is essentially going to print to an A4 sheet of 8 labels. On each label I want a customer name and order number, which is input via a UserForm. The...
  8. T

    Copy Transpose Paste Vertically Breaking on Blanks

    I am new to VBA and coding in general. I am trying to copy/transpose/paste a two-column PivotTable and I need it to paste vertically and break on blank rows. I need to copy each group in the PivotTable and transpose paste values vertically on a new worksheet. I cannot figure out how to...
  9. D

    Speeding Up For Each Loop Populating Table Rows

    I have worked pretty hard to come up with a solution that does what I had hoped but, it is SLOOOOOW!! Just under 28,000 rows of 8 columns took 19 minutes to process. Not acceptable! LOL! I am summarizing an application log. The process cycle creates three log lines per complete transaction. The...
  10. ChrisRamsden

    Loop extracting all data but then causing runtime error 13 (Type Mismatch)

    Hi Everyone, I am a brand new member, although i have been using MrExcel for tips and information for a few years now. I am currently writing an excel macro to pull data from another workbook by finding the number 4 and using offset to pick the cells i want to copy and paste. The macro is...
  11. P

    Connecting Pivot Tables Through Slicers after "show report page filters"

    HI ALL!! HELP ME PLEASE! 1) I am trying to create a separate Pivot Table for each pivot items using the below code. PivotTable Name = PivotTable_UBT Filter Item = Building ActiveSheet.PivotTables("PivotTable_UBT").ShowPages PageField:="Building" 2) Now i want to connect all the pivottables...
  12. C

    For Each Loop VBA Code Running Very Slow

    HI I got the following code from a forum a while back. It finds merged cells, un merges them and fills in the cell value. [CODE][Sub UnMergeFill() Dim cell As Range, joinedCells As Range For Each cell In ThisWorkbook.ActiveSheet.UsedRange If cell.MergeCells Then Set joinedCells...
  13. S

    Filling diferent sized boxes

    Hi, I have a problem at work which I'm trying to solve and was hoping someone could give me some pointers. I have simplified the problem below: I have varying sizes of pipe and varying sizes of baskets which I need to fill. I would like to be able to step through all of my baskets and check...
  14. S

    For loop not initilizing when identical loop runs fine

    While continuing my journey in teaching myself macro scripting, I've run into an error that has me a bit confused. What the macro should do: Populate and format a worksheet (Training Audit) based on information from a second worksheet (Reference Data). There are three categories (rau, qual...
  15. A

    Excel vba loop through list until

    Hello, I am trying to work on a way to automatically fill in a schedule for where someone should be. What I have so far is in my 1st sheet I have a table of cells I want to fill, across the columns i have dates, and down the rows I have the locations. In my 2nd sheet I have the dates of when...
  16. J

    Run an Independent Iteration of For Loop

    I can't figure this out for the life of me. If I was to run For j = 3 to 3 everything runs perfectly. When I run the loop For j = 0 to finalrowcust -1 it adds all kinds of stuff. I've tried to run a For k = 0 to finalrowcust -1 then For j = k to k, but that didn't work. I've also tried...
  17. C

    compounded return for each loop problem

    Hi, I'm trying to create a UDF function to calculate a return on a principal amount, with different interest rates for different periods. I know there are built in excel functions that can do this, but I'm trying to learn more about vba through this simple example. Here is what I've written...
  18. D

    Nested For Each Sheet Loop Issue

    Hey guys, I am trying to run the following (simplified) code: For Each sh In Worksheets ' I want to find if a particular sheet name exists If sh.Name = "Desired Name" Then ' Now as a result I want to perform changes on specific sheets For Each sh In Worksheets If sh.name =...
  19. H

    Add +1 in every for Next Loop

    Hello, For below standing code, I like would like to add one for every loop. Starting week is 1 and should be 2 in het second loop until the max number of weeks is reached (Loopcounter). Could someone help me out? Thanks, Hans Grandia Netherlands Sub Budget_Hourensou() Dim Counter As Integer...
  20. B

    For each loop TextBox data copy to excel

    Hi, I'm new to VBA so I get stuck from time to time :stickouttounge: Since a couple of days I was struggeling with the For Each Loop in combination with getting the value from textboxes in a userform and copying these to excel... The code picks up de data entered in the userform textbox's but...

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