Results 1 to 3 of 3

VBA code to create template

Threaded View

  1. #1
    Registered User
    Join Date
    11-19-2014
    Location
    Melbourne
    MS-Off Ver
    2010
    Posts
    10

    VBA code to create template

    Hi Guys

    I am trying to do couple of things.

    I want to compare the Department name in Sheet “Total employee” range A2:G2, with the other sheet names in the workbook. If the column value that is A2:G2 in Total employee (Department Name) not found in worksheet sheet names then, I want a message box “Sheet (name) not found, would you like to create one” and if user select Yes, then then the new sheet has to be created.
    The new sheet has to be created with the similar format like Policy, Marketing, finance with the relevant data from Total employee sheet.

    For example, there is no sheet name called HR in workbook.
    But in Sheet “Total employee” Department Name HR is present
    I want to create, a sheet name called HR and in that worksheet, I want to insert data based on sheet name

    HR
    LocationName Total employees Annual Salary Date of Join
    Location1 2
    Location3 7
    Location6 3

    I am started on it, but i am struck in the beginning state itself.
    Anyone help is much appreciated.


    Sub worksheetcheck()
    Dim wb As Workbook
    Dim sitename As String
    Dim rng As Range
    Dim i As Integer
    
    
    i = Application.Sheets.Count
    worksheetexist = False
    
    Set rng = ThisWorkbook.Sheets("Total employees").Range("b2:G2")
    For Each cell In rng
        For x = 1 To i
        '
    
    
            If cell.Value <> Worksheets(x).Name Then
                MsgBox cell.Value
                Exit For
            End If
        Next x
    Next cell
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 07-26-2013, 11:12 PM
  2. Replies: 3
    Last Post: 07-06-2012, 01:26 PM
  3. Code for copying a code into a specific place in an outlook template?
    By VoodooChild in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-21-2010, 10:08 AM
  4. Code to create copies of a 'template' sheet
    By Palaeontology in forum Excel General
    Replies: 6
    Last Post: 04-17-2010, 03:11 PM
  5. How can I create Macro that Create Template Fields?
    By sgraves in forum Word Programming / VBA / Macros
    Replies: 0
    Last Post: 07-17-2009, 11:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1