Excel - A macro to perform calculation and save data on another sheet

December 2016




Issue


I have a series of account numbers customers in column A. This list is of variable size.
My need is:
  • I have divided the list into pages of 40 counts.
  • I take 40 accounts in column A
  • I copy and I stick to a new sheet 1.
  • I am following the 40 and I paste them into a sheet 2. And etc ... until the last of the list. Could you help me, because VBA books for now it's Chinese to me? Thank you!

Solution


An example of how it should be:
Sub exploding () Dim sh As Worksheet, numf As Long, row As Long Set sh = ActiveSheet Application.ScreenUpdating = False numf = 1: = 1 For lig lig sh = 1 To. [A65536]. End (xlUp) Worksheets.Add after: = Worksheets (Worksheets.Count) ActiveSheet.Name = "Part" & numf ActiveSheet.Range ("A1: A40") = sh.Cells (lig, 1). Resize (40, 1). Value = lig lig + numf 39 + 1 = numf lig sh.Activate Next Application.ScreenUpdating = True End Sub 

You select the sheet in question before running the macro.
  • If he has a name determined replace:
  • Set sh = ActiveSheet
    • by:
  • Set sh = Worksheets ("name_ofthe_sheet)

Related :

This document entitled « Excel - A macro to perform calculation and save data on another sheet » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.