Solved

creat new tabs tabs

Posted on 2014-08-01
5
207 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 52

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 52

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

617 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