+ Reply to Thread
Results 1 to 3 of 3

copy a worksheet baised on a cell then hyperlinked

Hybrid View

  1. #1
    Registered User
    Join Date
    01-10-2013
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2010
    Posts
    2

    copy a worksheet baised on a cell then hyperlinked

    Hello guys and girls,

    would someone be able to help me with some VBA code please?
    I'm new to VBA programming but do have a fair knowledge of Delphi.

    What I am after is to click on cell A1 with value "November 2012" to look to see if there is a sheet with the name of that value, if there is to goto that sheet. If the sheet doesn't exist to copy a sheet named template and give it the value of A1. Then change a cell on the new sheet to one from the first sheet.

    Example of code;

    Cell A1 OnClick
    //Check to see if the sheet already exists with the value of A1

    DO Check workbook.sheets.name = Sheet1.A1.value;

    //If the sheet exists then go to it

    IF Check = TRUE THEN Go to workbook.sheet(A1)

    //If the sheet does not exist make from the template and rename it the value of A1

    ELSE DO
    Workbook.Sheet.Create FROM Workbook.sheet(Template);
    Workbook.sheet2(newsheet).name := Sheet1.A1.value;

    //change the value of cell A2 in the new sheet to be that if A1 in Sheet1

    Workbook.Sheet2(newsheet).A2.value := Sheet1.A1.value;
    END;
    END;
    END.

    thank you.

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: copy a worksheet baised on a cell then hyperlinked

    Clicking on a cell also happens when somebody wants to type in a value, so having the routine triggered by clicking on a cell is not the preferred way of doing this. You can either use a button or you can use the Worksheet_Change event to trigger the routine. Up to you. The enclosed example is based on a button.
    Attached Files Attached Files
    If you like my contribution click the star icon!

  3. #3
    Registered User
    Join Date
    01-10-2013
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: copy a worksheet baised on a cell then hyperlinked

    Thank you OllieB,

    Works brilianty, thank you for your time and effort.

+ 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