![]() But even this fearsome number is definitely wrong. That means that there will be 1571 loops - probably enough time to have a coffee and a chat even while screen updating is turned off. The loop will continue until the first row of the first range is equal to Rend. The line of code requiring your attention is this one. On each iteration the 3 ranges are moved one row down. Please check my code against your intentions in this regard. However, I have some doubt about the deletion and whether you actually meant to delete only this cell (which your code doesn't do). It makes no difference which cell in it is active. That's because C7 is within the range Range("B6:C1577") which is earmarked for destruction. ![]() You will notice that there is no equivalent of your Range("C7").Activate. It does so without selecting anything because once VBA is told where a range is it doesn't need to select it. The code copies from the first range to the second and then deletes the third. They are used to set 3 ranges in columns C, D and B:C. Start and End rows are specified at the top. Primary precaution to take is to understand the code. Set DelRng = Range(Cells(Rstart, "B"), Cells(Rend, "C")) Set Rng = Range(Cells(Rstart, "C"), Cells(Rend, "C")) Sub Macro1()ĭim Target As Range ' destination of copy action Please do not try this code without taking precautions. With wb.Worksheets(dstName).Range(dstFirstCell).Resize(, dcCount) ' Write values from Result Array to Destination Range. ' Write the remainder of values in Data Array to Result Array. ' Write values from Data Array to Result Array.įor i = 1 To drCount + (Remainder 0) * 1 ' In VBA 'True = -1'. ' Write values from Source Range to Data Array.ĭim srCount As Long: srCount = UBound(Data)ĭim Remainder As Long: Remainder = srCount Mod dCountĭim dcCount As Long: dcCount = dCount + 1ĭim Result As Variant: ReDim Result(1 To drCount, 1 To dcCount) Resize(rng.Row - srcFirstRow + 1).Offset(srcFirstRow - 1) With wb.Worksheets(srcName).Columns(srcColumns) Note that you can choose a different worksheet for the result to leave your source data intact.ĭim wb As Workbook: Set wb = ThisWorkbook
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |