View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default Loop for myRng for next set of 9 rows

Wow! Kinda where I was going...

Option Explicit

Type udtAppModes
'Default types
Events As Boolean: CalcMode As XlCalculation: Display As Boolean:
CallerID As String
'Project-specific types
End Type
Public AppMode As udtAppModes


Sub ColBlocksToRows2()
' Transposes blocks of column data to row data.
Const sSource$ = "ColBlocksToRows2"

Dim n&, lRow&, lLastRow&, rng As Range
Const lStartRow& = 11 '//edit to suit

On Error GoTo ErrExit: EnableFastCode sSource

lRow = 1 '//initialize for counter increment
lLastRow = Cells(Rows.Count, 1).End(xlUp).Row
For n = lStartRow To lLastRow Step 10
Set rng = Cells(n, 1).Resize(9): lRow = lRow + 1
Range("D" & lRow).Resize(1, 9) = _
Application.Transpose(rng)
Next

ErrExit:
Set rng = Nothing: EnableFastCode sSource, False
End Sub 'ColBlocksToRows2


'--------------------------------------------------------------------------------------
' **Note: EnableFastCode requires the following declarations be in a
standard module.
'--------------------------------------------------------------------------------------
'Type udtAppModes
' 'Default types
' Events As Boolean: CalcMode As XlCalculation: Display As Boolean:
CallerID As String
' 'Project-specific types
'End Type
'Public AppMode As udtAppModes
'--------------------------------------------------------------------------------------
Sub EnableFastCode(Caller$, Optional SetFast As Boolean = True)
' **Note: Requires 'Type udtAppModes' and 'Public AppMode As
udtAppModes' declarations

'The following will make sure only the Caller has control,
'and allows any Caller to take control when not in use.
If AppMode.CallerID < Caller Then _
If AppMode.CallerID < "" Then Exit Sub

With Application
If SetFast Then
AppMode.Display = .ScreenUpdating
.ScreenUpdating = False
AppMode.CalcMode = .Calculation
.Calculation = xlCalculationManual
AppMode.Events = .EnableEvents
.EnableEvents = False
AppMode.CallerID = Caller
Else
.ScreenUpdating = AppMode.Display
.Calculation = AppMode.CalcMode
.EnableEvents = AppMode.Events
AppMode.CallerID = ""
End If
End With
End Sub

...but I didn't see the need for using CountA since we're looping from
start row to last row of data.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion