+ Reply to Thread
Results 1 to 7 of 7

Check First IF Sheet Is Exist With The Name Of Cell K7 If exist Then run the code

  1. #1
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,078

    Post Check First IF Sheet Is Exist With The Name Of Cell K7 If exist Then run the code

    Hello, everyone
    I want when i run this code :
    Please Login or Register  to view this content.
    then first check the sheet name is exist according to Cell "K7". if sheet exist then run the code otherwise inform me "the sheet is not exist please create the sheet first"
    Sheet name = whatever value is in Cell "K7",
    if "K7" = 7.1.14 then sheet name should be "7.1.14"

    thanx

  2. #2
    Registered User
    Join Date
    12-03-2013
    Location
    Mumbai
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Check First IF Sheet Is Exist With The Name Of Cell K7 If exist Then run the code

    Hi Haroonsid,

    Please try the below code and see if it works.

    Sub Test()
    Dim sh As Worksheet
    Dim flg As Boolean
    Dim Name As String
    Name = Range("K7").Value
    For Each sh In Worksheets
    If sh.Name = Name Then flg = True: Exit For

    Next
    If flg = True Then
    Sheets(Name).Select
    Range("C7:F10000,H7:H10000,J7:J10000").Select
    Range("J7").Activate
    Selection.ClearContents
    Range("C7").Activate
    Else
    MsgBox "the sheet is not exist please create the sheet first"
    End If
    End Sub

    If this solves your problem please tag this post as solved and add reputation.

    Regards,
    Raghu

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,090

    Re: Check First IF Sheet Is Exist With The Name Of Cell K7 If exist Then run the code

    Please Login or Register  to view this content.

    Regards, TMS
    Last edited by TMS; 01-18-2015 at 06:27 AM. Reason: Re-order code (move for testing line)
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Check First IF Sheet Is Exist With The Name Of Cell K7 If exist Then run the code

    Hi, HaroonSid,

    maybe try
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  5. #5
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,078

    Re: Check First IF Sheet Is Exist With The Name Of Cell K7 If exist Then run the code

    Hi, Raghukumarn
    Plz use code tag for code
    thanx
    Use Code-Tags for showing your code :
    Please mark your question Solved if there has been offered a solution that works fine for you
    If You like solutions provided by anyone, feel free to add reputation using STAR *

  6. #6
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,078

    Re: Check First IF Sheet Is Exist With The Name Of Cell K7 If exist Then run the code

    @Raghukumarn, @Tms, And My dear @HaHoBe

    Thanx Alot I got The Solution.
    all of three method is working well as i wanted.......will add all of you reputation surely.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,090

    Re: Check First IF Sheet Is Exist With The Name Of Cell K7 If exist Then run the code

    You're welcome. Thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] check column headers against sheet names if sheet not exist create it
    By AkaTrouble in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-13-2015, 05:59 PM
  2. Replies: 0
    Last Post: 02-23-2014, 10:31 PM
  3. macro to check if a value exist in sheet and add it if it doesnt
    By RetroGun in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-01-2011, 02:35 AM
  4. macro to check if a value exist in sheet and add it +other parts of row if it doesnt
    By RetroGun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2011, 07:14 AM
  5. when typing to a cell check if this number exist in a range of cells (in sheet 2)
    By gtserkou in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-28-2008, 01:18 PM

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