+ Reply to Thread
Results 1 to 6 of 6

Macro to Name Sheet

  1. #1
    Dolphinv4
    Guest

    Macro to Name Sheet

    Hi,

    I want my sheet name to automatically be named as Date(Adj) whereby the Date
    will be obtained from cell A1. This is what i did but it don't work. What's
    wrong?

    Sub New_Month()

    Dim myAdjName As String

    myAdjName = Format(Range("A1").Value, "mmm") & "(ADJ)"
    ActivSheet.Name = myAdjName

    End Sub

    Thanks!

  2. #2
    Forum Contributor
    Join Date
    02-15-2005
    Location
    Blackpool, UK
    Posts
    137
    Hi Dolphinv4,

    I have had the same problem with Range, the macro looks like it should work, but doesn't.

    The solution is that Range sometimess needs to be in the format expression.range. For your macro try:

    myAdjName = Format(Worksheets(1).Range("A1").Value, "mmm") & "(ADJ)"

    Adjust the Worksheets(x) value accordingly.

    HTH

    Art

  3. #3
    Stefi
    Guest

    RE: Macro to Name Sheet

    You misspelled
    > ActivSheet.Name = myAdjName

    Insert an "e":
    ActiveSheet.Name = myAdjName
    Regards,
    Stefi


    „Dolphinv4” ezt *rta:

    > Hi,
    >
    > I want my sheet name to automatically be named as Date(Adj) whereby the Date
    > will be obtained from cell A1. This is what i did but it don't work. What's
    > wrong?
    >
    > Sub New_Month()
    >
    > Dim myAdjName As String
    >
    > myAdjName = Format(Range("A1").Value, "mmm") & "(ADJ)"
    > ActivSheet.Name = myAdjName
    >
    > End Sub
    >
    > Thanks!


  4. #4
    Dolphinv4
    Guest

    RE: Macro to Name Sheet

    Hi,

    the prob is not with the typo. I realised it later and changed but it still
    don't work.

    Regards,
    Dolphin

    "Stefi" wrote:

    > You misspelled
    > > ActivSheet.Name = myAdjName

    > Insert an "e":
    > ActiveSheet.Name = myAdjName
    > Regards,
    > Stefi
    >
    >
    > „Dolphinv4” ezt *rta:
    >
    > > Hi,
    > >
    > > I want my sheet name to automatically be named as Date(Adj) whereby the Date
    > > will be obtained from cell A1. This is what i did but it don't work. What's
    > > wrong?
    > >
    > > Sub New_Month()
    > >
    > > Dim myAdjName As String
    > >
    > > myAdjName = Format(Range("A1").Value, "mmm") & "(ADJ)"
    > > ActivSheet.Name = myAdjName
    > >
    > > End Sub
    > >
    > > Thanks!


  5. #5
    Dolphinv4
    Guest

    Re: Macro to Name Sheet

    Hi,

    but I need this macro to work in every new sheet created, thus I can't put
    in a specific "worksheet" name. I tried using "ActiveSheet" instead but it
    doesn't work. Please help!

    myAdjName = Format(ActiveSheet.Range("A1").Value, "mmm") & "(ADJ)"
    ActiveSheet.Name = myAdjName

    Thanks,
    Val.
    "HiArt" wrote:

    >
    > Hi Dolphinv4,
    >
    > I have had the same problem with Range, the macro looks like it should
    > work, but doesn't.
    >
    > The solution is that Range sometimess needs to be in the format
    > -expression-.range. For your macro try:
    >
    > myAdjName = Format(*Worksheets(1).*Range("A1").Value, "mmm") & "(ADJ)"
    >
    > Adjust the Worksheets(x) value accordingly.
    >
    > HTH
    >
    > Art
    >
    >
    > --
    > HiArt
    > ------------------------------------------------------------------------
    > HiArt's Profile: http://www.excelforum.com/member.php...o&userid=19953
    > View this thread: http://www.excelforum.com/showthread...hreadid=472032
    >
    >


  6. #6
    Dolphinv4
    Guest

    IT WORKS! THANKS! Re: Macro to Name Sheet

    Hi,

    i just realised it does work after I used "ActiveSheet" in your formula.
    Thanks!

    Val

    "Dolphinv4" wrote:

    > Hi,
    >
    > but I need this macro to work in every new sheet created, thus I can't put
    > in a specific "worksheet" name. I tried using "ActiveSheet" instead but it
    > doesn't work. Please help!
    >
    > myAdjName = Format(ActiveSheet.Range("A1").Value, "mmm") & "(ADJ)"
    > ActiveSheet.Name = myAdjName
    >
    > Thanks,
    > Val.
    > "HiArt" wrote:
    >
    > >
    > > Hi Dolphinv4,
    > >
    > > I have had the same problem with Range, the macro looks like it should
    > > work, but doesn't.
    > >
    > > The solution is that Range sometimess needs to be in the format
    > > -expression-.range. For your macro try:
    > >
    > > myAdjName = Format(*Worksheets(1).*Range("A1").Value, "mmm") & "(ADJ)"
    > >
    > > Adjust the Worksheets(x) value accordingly.
    > >
    > > HTH
    > >
    > > Art
    > >
    > >
    > > --
    > > HiArt
    > > ------------------------------------------------------------------------
    > > HiArt's Profile: http://www.excelforum.com/member.php...o&userid=19953
    > > View this thread: http://www.excelforum.com/showthread...hreadid=472032
    > >
    > >


+ 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