View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Help with vb Bot

Paulo,

You need to select a single cell within your contiguous database (no blank rows or columns) prior to
running the code.

HTH,
Bernie
MS Excel MVP


"Paulo" wrote in message
...
Thank you very much for your help Bernie,

I am begginer @ VBA so i am walking 1 step afthe the other...

I tried your code, but i am getting erro in this line.

Set myArea = myArea.Resize(myArea.Rows.Count - 1, 1)



"Bernie Deitrick" wrote:

Paulo,

If you have a table with headers in the first row, try the macro below.

HTH,
Bernie
MS Excel MVP

Sub ExportSheetsFromDatabase()
'Based on the value in the first column
Dim myCell As Range
Dim mySht As Worksheet
Dim myName As String
Dim myArea As Range

Set myArea = ActiveCell.CurrentRegion.Columns(1).Offset(1, 0).Cells

Set myArea = myArea.Resize(myArea.Rows.Count - 1, 1)

For Each myCell In myArea
On Error GoTo NoSheet
myName = Worksheets(myCell.Value).Name
GoTo SheetExists:
NoSheet:
Set mySht = Worksheets.Add
mySht.Name = myCell.Value
With myCell.CurrentRegion
.AutoFilter Field:=1, Criteria1:=myCell.Value
.SpecialCells(xlCellTypeVisible).Copy _
mySht.Range("A1")
mySht.Cells.EntireColumn.AutoFit
.AutoFilter
End With
Resume
SheetExists:
Next myCell
End Sub


"Paulo" wrote in message
...
I have a spreadsheet that has 2 colums and 5 rows

lets say it looks like this...

banana;10
apple;15
grapes;12
grapes;2
banana;7
I woul like to make a macro that
creates a single tab for each different fruit
so I would start with the original sheet 1 and after runing the macro I
would end up with 4 , the original, plus 1 banana tab, 1 grape tab and 1
apple tap
the second part would copy and past the rows that has the fruit in side the
specific tab.

i thanks in advance for the help