+ Reply to Thread
Results 1 to 5 of 5

Ignor blank cells

  1. #1
    Forum Contributor
    Join Date
    08-10-2006
    Posts
    723

    Question Ignor blank cells

    hi,

    i am trying to add worksheets to my work book by using information from certain cells. if by any chance one of the cells is left blank an error message appears ie d1

    could you please look at the workbook and advise what is wrong please

    thank you

    steve
    Attached Files Attached Files

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi Try

    On error resume next.

    Look at the attached to learn more about error trapping

    http://www.cpearson.com/excel/ErrorHandling.htm

    VBA Noob

  3. #3
    Forum Contributor
    Join Date
    08-10-2006
    Posts
    723

    ignor blank cell

    hi,

    when i put the error trap in, i do not get the error message but a worksheet still is generated. could you please advise how to stop that

    thanks for your help

    steve

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Angry

    Hi Steve the last code I gave you didn't work so hot, it should have gone into a workbook module, here's the revised code


    Option Explicit

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Static lRows As Long
    Dim lTemp As Long
    'Only track the first sheet or by name
    If Sh.Name = "Sheet1" Then
    'Only if the changed cell is in Column A
    If Target.Column = 1 Then
    'Get the last row in the used range
    lTemp = Sheet1.UsedRange.End(xlUp).Row
    If lTemp > lRows Then
    'Add a new sheet and rename it
    Sheets.Add After:=Sheets(Sheets.Count)
    Sheets(Sheets.Count).Name = Target
    End If
    End If
    End If
    End Sub



    Good luck

  5. #5
    Forum Contributor
    Join Date
    08-10-2006
    Posts
    723

    ignor blank cell

    thanks

    it works a treat

    thanks again steve

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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