On Dec 25, 1:19*pm, joel <joel.43r...@thecodecage.com> wrote:
> Try this code. *It should work. *fully tested
>
> Sub formatData()
>
> Set SourceSht = Sheets(1)
>
> NewRowCount = 2
> NewColCount = 3
> SheetCount = 1
> With SourceSht
> 'If data start i A1 then add new row
> If .Range("A1") <> "Inst. No." Then
> .Rows(1).Insert
>
> With Sheets(SheetCount)
> .Range("A1") = "Inst. No."
> .Range("B1") = "Memo"
> With .Cells.Font
> .Name = "Arial"
> .FontStyle = "Regular"
> .Size = 10
> End With
> End With
> End If
>
> .Range("C1") = "Inst. No."
> .Range("D1") = "Memo"
>
> RowCount = 2
> Do While .Range("A" & RowCount) <> ""
> If NewRowCount > 58 Then
> NewColCount = NewColCount + 2
> 'create new sheet
> If NewColCount > 8 Then
> If SheetCount = Sheets.Count Then
> 'add new sheet
> Sheets.Add after:=Sheets(Sheets.Count)
> End If
> SheetCount = SheetCount + 1
> With Sheets(SheetCount).Cells.Font
> .Name = "Arial"
> .FontStyle = "Regular"
> .Size = 10
> End With
> NewColCount = 1
> End If
>
> With Sheets(SheetCount)
> .Cells(1, NewColCount) = "Inst. No."
> .Cells(1, NewColCount + 1) = "Memo"
> End With
> NewRowCount = 2
> End If
>
> Sheets(SheetCount).Cells(NewRowCount, NewColCount) = _
> .Range("A" & RowCount)
>
> NewRowCount = NewRowCount + 1
> RowCount = RowCount + 1
> Loop
>
> 'Delete data from sheet 1
> LastRow = .Range("A" & Rows.Count).End(xlUp).Row
> If LastRow > 58 Then
> .Rows("59:" & LastRow).Delete
> End If
> End With
> End Sub
>
> --
> joel
> ------------------------------------------------------------------------
> joel's Profile: 229
> View this thread:http://www.thecodecage.com/forumz/sh...d.php?t=165111
>
> Microsoft Office Help
Hey joel,
This is a great solution, and I only found one small bug.
I'm just wondering also, is it possible at all to have the macro act
to use a single sheet for the resulting, formatted data?
- Currently, when it runs, it breaks out the same numbers in column B
as in column A - but only on the first sheet. After that, each column
is unique (on subsequent sheets).
- In terms of using a single sheet, is it possible to have the numbers
broken out on one sheet, rather than using a separate sheet for each
new page? There are a couple of reasons to this, one being that I
have another automated function that formats a sheet at a time. I've
ran it using some data and it produced 70+ sheets...
I think the existing code (the code I pasted, that is) had to modified
a couple of times to compensate for a similar issue I was having when
I first developed it.
Hope your day is a great one,
randy