View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
manfareed manfareed is offline
external usenet poster
 
Posts: 94
Default New Sheet based on condition

It is a spreadsheet from someone else which I am trying to make sense of and
in effect tidy up.

It contains individual employee details in column"A" and their manager
Names in column "F". All this data is contained in 1 sheet. I need to create
new sheets for each of the managers. Each sheet would be named after the
manager and show only his employees.

Thanks

"Mike H" wrote:

That's not clearer. Column F is a list of names when any code runs so what is
it compared with?

"manfareed" wrote:

Thanks for your replies. Sorry for not being clear earlier.
Need code to check for a new name in column F.
I will test John's code and let you know.
Thanks,

Manir

"john" wrote:

not sure if I've fully understood what you are trying to do an mikes comment
aludes to lack of clear info.

As stab in the dark something along the lines of following may do what you
want? but there again, could be miles off!

Sub NewSheet()
Dim sh As Worksheet
Dim NewName As String


Application.ScreenUpdating = False

RN = 27
With ThisWorkbook.Worksheets("Sheet1") '<< change as required

LastRow = .Cells(Rows.Count, "F").End(xlUp).Row

.Range("F27:F" & LastRow).Sort Key1:=.Range("F27"),
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Do

NewName = .Range("F" & RN).Value

On Error Resume Next

Set sh = Worksheets(NewName)

On Error GoTo 0

If sh Is Nothing Then
Worksheets.Add.Name = (NewName)
End If

RN = RN + 1

Loop Until .Range("F" & RN).Value = ""

End With

Application.ScreenUpdating = True

End Sub

--
jb


"manfareed" wrote:

Hi ,

I need to sort data by column F [FROM F27]. Then create new sheets based on
each new name in column F.

Thanks