Solved

creat new tabs tabs

Posted on 2014-08-01
5
203 Views
Last Modified: 2014-08-01
Can an Expert provide me with VBA code that will create a new tab for any items ic column J where the date in column B is Today.

There will be mutiple items in 'J' with the same name but I only want one tab per name.

i.e.

Date      Ref
01/08/2014      CLOVC
01/08/2014      CLOVC
01/08/2014      CLOVC
01/08/2014      BKIDQ
02/08/2014      BKIDQ
02/08/2014      CLOVC
01/08/2014      SUUKG
02/08/2014      MSSU0

So I would tabs created for CLOVC, BKIDQ, SUUKG

Thanks in advance
0
Comment
Question by:Jagwarman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 51

Expert Comment

by:Rgonzo1971
ID: 40233755
Hi,

pls try

Sub macro()

For Each c In Range(Range("J2"), Range("J" & Rows.Count).End(xlUp))
    If c.Offset(0, -9) = Date Then
        On Error Resume Next
        Set Sh = Nothing
        Set Sh = ActiveWorkbook.Worksheets(c.Value)
        On Error GoTo 0
        If Sh Is Nothing Then
            ActiveWorkbook.Sheets.Add After:=Worksheets(Worksheets.Count)
            Worksheets(Worksheets.Count).Name = c.Value
        End If
    End If
Next
End Sub

Open in new window

Regards
0
 

Author Comment

by:Jagwarman
ID: 40233783
Hi Rgonzo1971

code runs from start to end but no sheets are being created.

When I step through code it looks ok but no tabs????
0
 
LVL 51

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40233811
Amended code

Sub macro()

For Each c In Range(Range("J2"), Range("J" & Rows.Count).End(xlUp))
    If c.Offset(0, -8) = Date Then
        On Error Resume Next
        Set Sh = Nothing
        Set Sh = ActiveWorkbook.Worksheets(c.Value)
        On Error GoTo 0
        If Sh Is Nothing Then
            ActiveWorkbook.Sheets.Add After:=Worksheets(Worksheets.Count)
            Worksheets(Worksheets.Count).Name = c.Value
        End If
    End If
Next
End Sub
0
 

Author Comment

by:Jagwarman
ID: 40233822
Brilliant thanks
0
 

Author Comment

by:Jagwarman
ID: 40233832
I have a related question which I am now going to post which is for each tab created I need to put its relative data onto that tab If I had thought about it earlier maybe it could have been one post but this way you get more points :-)   if you respond
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question