LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default VBA Macro to Create Sheets Based on Column of Values

Good Afternoon,

This code worked for me on your sample workbook. It uses an input box to have the user select a range with the Carrier names rather than using the ActiveCell approach. This helps ensure that your are running the code only on those cells that you want to create tabs for. Still, it will end the sub upon encountering a "0", so feel free to select the entire range you need if you wish.

To use this, just paste the code below to a module in your sheet. Hope this helps.

Ben

Option Explicit

Sub ParseCarriers()
Dim rCell As Range
Dim rCarriers As Range
Dim wsNew As Worksheet
Dim wsCarriers As Worksheet

On Error Resume Next
Set rCarriers = Application.InputBox("Please select the range of Carrier names to add", "Carrier Selection", , , , , , 8)
If rCarriers Is Nothing Then Exit Sub
On Error GoTo 0

Set wsCarriers = Sheets("Carrier Specific")
Application.ScreenUpdating = False

For Each rCell In rCarriers
If rCell.Value = 0 Then GoTo ExitHere
wsCarriers.Copy After:=Sheets(Sheets.Count)
Set wsNew = ActiveSheet
On Error Resume Next
wsNew.Name = rCell.Value
On Error GoTo 0
wsNew.Range("D1").Value = rCell.Value
Next rCell

ExitHe
Application.ScreenUpdating = True
End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create New Sheets and Name Them Based on Values in another sheet KennyD Excel Discussion (Misc queries) 2 January 28th 10 06:51 PM
Macro to Create Worksheets Based on Cell Values Lilbit Excel Worksheet Functions 3 March 24th 08 05:39 PM
Create 2 sheets, from one, based upon value of one column NickR2 Excel Worksheet Functions 5 December 26th 07 01:03 PM
CREATE NEW WORKBOOK AND SHEETS BASED ON COLUMN DATA control freak Excel Worksheet Functions 2 July 20th 06 06:00 PM
Create Worksheets Based Upon Changing Column Values in XP Gary[_12_] Excel Programming 1 December 18th 03 12:07 AM


All times are GMT +1. The time now is 03:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"