excel - For each Worksheet in Worksheets not working -
I'm new to VBA coding instead, so excuse my ignorance, because I'm probably doing something simple simple here I am I have written a small VBA script that aligns data for a worksheet, using a master list of names as a reference point.
This works fine on a worksheet at a time, but when "worksheets in each worksheet" is entered in the loop, it applies to the first worksheet and then closes. It has been debugged, and the "for each" part is working, but any suggestions that the code from the worksheet is not being used before?
I have tried to speed up Dim both inside and outside of "each" variable, and there is no difference between it. All the references to the worksheet in the code are changing variables with each step I understand.
I have suggested that the code has been edited, and it still applies only to the first worksheet: Other simple solutions: < / P>
option clear sub alignAll () Long as long as the worksheet, as long as the worksheet, I have long as, in the form of a range, as a range set c = worksheets ("masterlist"). This workbook for range ("A6: A 20000") I = 1 Worksheets. Set up current = this workbook Sheets (i) if present. Name & lt; & Gt; "Yearly" and present. Name & lt; & Gt; "Masterlist" then stop 'conflicts n = cell.qualitycale (11) .ro sets the category of current worksheet and class of Master list as C. Set = Current.Range ("A6: A200") A (N + 1) = CHR (255): c (n + 1) = chr (255) a.Sort a (1), 1, Header: = XlNo c. Cort c (1), 1, Header: = xlNo Do x = x + 1 'step through each category if one (x) & gt; C then connects the rows such as data needs to be aligned (x). Interval Built-in xlShiftDown closing if X & gt; Exit 10 ^ 4 then a (x) = Chr (255) and c (x) = Chr (255) a (x) two loops. Light chest: c (x). Clear Content 'resets end if the next I end sub
options clear sub alignAll () as slow current in the worksheet dim as the current worksheet dim N, long as long as X, I have long 'Restart a boundary range as error' is really needed? It may be possible to (temporarily) remove the problem (temporarily) to debug it, to debug ... ActiveWorkbook from I = 1 .orksheets.count set current = ActiveWorkbook.Sheets (i) 'Stuff Next I End sub / div>
Comments
Post a Comment