VBA to Define new worksheet with custom name and check if it exists

  • Dear all,
    I am trying to define a new sheet with custom name and check if it exits before i do something with code..
    Actually in long run i will add this sheet. Before i need to make a cross check if it exists.
    But my code throws an error. Please help me fix this error.
    Below is my code..


  • Re: VBA to Define new worksheet with custom name and check if it exists


    You have to set a worksheet variable to a worksheet before you can use it.


    Normally something like this.

    Code
    1. Dim ws as Worksheet
    2. Set ws = Worksheets("Sheet1")


    You are just diving right in with Tsh.Name when you haven't set the sheet first.

    Bruce :cool:

  • Re: VBA to Define new worksheet with custom name and check if it exists


    Maybe you want something like this. :cool:

    Bruce :cool:

  • Re: VBA to Define new worksheet with custom name and check if it exists


    Haan..Got your point...Works cool...Thanks for your fast response..:)
    Have a gr8 day..:)