+ Reply to Thread
Results 1 to 8 of 8

need a VBA code to change and create sheets name according to the selected month.

  1. #1
    Forum Contributor
    Join Date
    02-10-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    2016
    Posts
    173

    need a VBA code to change and create sheets name according to the selected month.

    hi guys!

    i am trying to create workbook in which i will collect data on daily biases. Therefore, ever month i need to change/create sheet names according to the selected month (month selection is in sheet no 12) dates. Now i need a VBA code which automatically create/change sheets name.

    Note: i have data in from sheet 1 to sheet 12. VBA should create/change sheet after sheet No. 12.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: need a VBA code to change and create sheets name according to the selected moth.

    try such code and adopt it to your needs:
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Forum Contributor
    Join Date
    02-10-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    2016
    Posts
    173

    Re: need a VBA code to change and create sheets name according to the selected moth.

    actually i need sheets name as selected months date. if a month have 31 days automatically 31 sheets created with date names.

    and month will be selected from sheet:1 Row:2 & Column:C

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: need a VBA code to change and create sheets name according to the selected moth.

    Please Login or Register  to view this content.
    Try such code - not tested, because you attached no file.
    Notes:
    - if by sheet:1 you not ment first sheet but sheet where tab with sheetname change bot sheets(1) to sheets("1")
    - cell c2 in sheet 1 shall have month number in it otherwise sheets(1).cells(2,"C") will mot be valid - change procedure accordingly

  5. #5
    Forum Contributor
    Join Date
    02-10-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    2016
    Posts
    173

    Re: need a VBA code to change and create sheets name according to the selected moth.

    I have attached sample file in which i would like to change month in sheet:1 row:2 column:C than VBA/MACRO will auto create sheets according numbers of days of selected month and name those sheets as 1, 2, 3. and remove sheet no 31 if month have 30 days
    Attached Files Attached Files

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: need a VBA code to change and create sheets name according to the selected moth.

    If you want the process to happen every time you chanche C2 then add the code:
    Please Login or Register  to view this content.
    to your sheet1 code (it's already ther in the attachment. If yo do not want such action - delete it)
    and main code in standard module:
    Please Login or Register  to view this content.
    If you delete first code, you will have to run this as any other macro: Alt+F8 select name and Run
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    02-10-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    2016
    Posts
    173

    Re: need a VBA code to change and create sheets name according to the selected month.

    when i paste those code in my file below mentioned error

    Untitled.jpg

  8. #8
    Forum Contributor
    Join Date
    02-10-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    2016
    Posts
    173

    Re: need a VBA code to change and create sheets name according to the selected month.

    after playing with codes finally i solved it. Thank you Kaper.

+ 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] VBA Code Change Event Code When 2 cells are selected
    By bjnockle in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-16-2014, 06:08 PM
  2. Create Macro to Print Selected Section that may change in row placement from month to mont
    By Frenchqtrgirl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-27-2013, 05:03 PM
  3. create a formula to select selected inventory by month
    By refrigerationguy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-28-2009, 05:08 PM
  4. Replies: 6
    Last Post: 03-29-2006, 07:50 AM
  5. [SOLVED] How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook?
    By Dmitry in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-29-2006, 07:50 AM
  6. Replies: 6
    Last Post: 03-29-2006, 07:50 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