Hi,
I have this fabulous macro which copies a specified range after each iteration:
I wonder if there is a way to change the code to copy dynamic range at each calculation?
can it be made to copy dynamic number of rows based on the text in a cell???
eg change A133:WVD160 to A133:b160 take it from cell a1
Dave
I have this fabulous macro which copies a specified range after each iteration:
VBA Code:
Sub ARUN()
Application.ScreenUpdating = False
Dim WorkingSht As Worksheet, i As Long, j As Long, k As Long, n As Long, newSht As Worksheet, DestnRow As Long
Dim SourceRng As Range, SourceWidth As Long, SourceHeight As Long, GapBetweenResults As Long
Set WorkingSht = ActiveSheet
'Set newSht = Sheets.Add(after:=Sheets(Sheets.Count))
Set newSht = Sheets("RESULTS")
newSht.Range("A:CG").ClearContents
GapBetweenResults = 0 'adjust to change the gap between results blocks.
DestnRow = 3
With WorkingSht
.Activate 'optional
Set SourceRng = .Range("A133:WVD160")
SourceWidth = SourceRng.Columns.Count
SourceHeight = SourceRng.Rows.Count
GapBetweenResults = SourceHeight + GapBetweenResults
For i = 170 To 309
If i Mod 10 = 0 Then ActiveWorkbook.Save
.Range("O39") = i
For j = 1 To 24
.Range("P39") = j
'do your result grabbing here:
Calculate
newSht.Cells(DestnRow, 1).Resize(SourceHeight, SourceWidth).Value = SourceRng.Value
DestnRow = DestnRow + GapBetweenResults
Next j
Next i
End With
Application.Calculation = xlCalculationAutomatic
ActiveWorkbook.Save
Application.ScreenUpdating = True
End Sub
I wonder if there is a way to change the code to copy dynamic range at each calculation?
can it be made to copy dynamic number of rows based on the text in a cell???
eg change A133:WVD160 to A133:b160 take it from cell a1
Dave
VBA Code: