View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
jetted[_12_] jetted[_12_] is offline
external usenet poster
 
Posts: 1
Default Macro to split workbook into several based on cell contents


Hi

Would this work?
Sub create_worksheet()
branch = "Branch Name"
sale = "Sales Persons"
figur = "Sales Figures"

rowcount = Cells(Cells.Rows.Count, "a").End(xlUp).Row
For i = 2 To rowcount
'Assuming the info is on sheet1, if not change the name
Sheets("sheet1").Activate
Range("a" & i).Select
w_name = ActiveCell.Value
Range("b" & i).Select
salep = ActiveCell.Value
Range("c" & i).Select
salef = ActiveCell.Value
Worksheets.Add
ActiveSheet.Name = w_name
ActiveSheet.Activate
Range("a1").Select
ActiveCell = branch
Range("a2").Select
ActiveCell = w_name
Range("b1").Select
ActiveCell = sale
Range("b2").Select
ActiveCell = salep
Range("c1").Select
ActiveCell = figur
Range("c2").Select
ActiveCell = salef

Next
'Assuming the info is on sheet1, if not change the name
Sheets("sheet1").Activate
End Su

--
jette
-----------------------------------------------------------------------
jetted's Profile: http://www.excelforum.com/member.php...fo&userid=1753
View this thread: http://www.excelforum.com/showthread.php?threadid=56320