How to insert rows dynamically with in group
Solved/Closed
alveeru
-
Dec 18, 2010 at 09:57 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Feb 9, 2011 at 10:29 PM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Feb 9, 2011 at 10:29 PM
Related:
- How to insert rows dynamically with in group
- How to insert photo in word for resume - Guide
- Insert check mark in word - Guide
- Insert key - Guide
- How to insert at the rate in laptop - Guide
- Insert draft watermark in word on all pages - Guide
1 response
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Feb 9, 2011 at 10:29 PM
Feb 9, 2011 at 10:29 PM
see if this helps
Sub doDataGroup()
Dim lCount As Long 'total items to be grouped
Dim iMaxSheetItem As Integer 'max items on one sheet
Dim iSheetNeed As Integer 'calculated number of sheets needed
Dim iCounter As Integer 'counter to loop thru sheets
Dim iSheetItem As Integer 'number of items of the sheet being processed
Dim iRemainder As Integer
iMaxSheetItem = 10
lCount = 37 'example that there are 37 total items
iRemainder = lCount Mod iMaxSheetItem
iSheetNeed = ((lCount - iRemainder) / iMaxSheetItem) + IIf(iRemainder > 0, 1, 0)
For iCounter = iSheetNeed To 1 Step -1
iRemainder = lCount Mod iCounter
iSheetItem = ((lCount - iRemainder) / iCounter) + IIf(iRemainder > 0, 1, 0)
lCount = lCount - iSheetItem
Debug.Print "Item on Sheet " & iCounter & ": " & iSheetItem
Next iCounter
End Sub