+ Reply to Thread
Results 1 to 6 of 6

copy existing code for another sheet

  1. #1
    Registered User
    Join Date
    06-27-2012
    Location
    Kuala Lumpur, Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Post copy existing code for another sheet

    Hi,
    Really need your advice.

    1stly i never do vb macro before.
    i have 1 excel with currently have 3 sheet coded with vb. This macro will call the excel source to display the filename accordingly in grouping.

    Let say.
    Sheet1 - will call the text having *OM4* and display in OM4 sheet
    Sheet2 - will call the text having *OM5* and display in OM5 sheet
    Sheet3 - will call the text having *OM6* and display in OM5 sheet

    Now, company need me to add one more sheet called OM3 which will have in excel source soon.

    Question :
    Can i copy VB code from current OM4/OM5 sheet to the new sheet (OM3) and just rename the OM4 to OM3 in that code? Do i need to change anything else such as declaration and else? I tried to copy code from OM4 and paste into OM3 sheet using VB editor with just renamed OM4 to OM3.. but failed!. the ouput in OM3 is same as OM4 which i copied code from.

    Please advice. Thanks in advance.


    *Uploaded excel sheet in the question.
    Not working sheet - SHEET1 and SUMMARY
    Need to change SHEET1 to OM3 which will newly added.
    Last edited by defarny37; 06-27-2012 at 07:10 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: copy existing code for another sheet

    Hi,

    Difficult to say without seeing the workbook in question. But for starters I suggest you right click on one of the current sheet tab names, choose Move or Copy and then tick the 'Copy' box and then OK.

    Change the sheet name to OM3 and check the VBA code for any references to the OM number of the sheet you copied and change to OM3.

    Then try running your macros.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    06-27-2012
    Location
    Kuala Lumpur, Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: copy existing code for another sheet

    Quote Originally Posted by Richard Buttrey View Post
    Hi,

    Difficult to say without seeing the workbook in question. But for starters I suggest you right click on one of the current sheet tab names, choose Move or Copy and then tick the 'Copy' box and then OK.

    Change the sheet name to OM3 and check the VBA code for any references to the OM number of the sheet you copied and change to OM3.

    Then try running your macros.
    Thanks Richard!
    But as tried, the output will be the same as sheet i copied code from. Just the text different. Its getting really hard..;(

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: copy existing code for another sheet

    In that case upload the workbook in question as requested and add some notes explaining precisely what you expect to happen with reference to specific cells/sheets.

  5. #5
    Registered User
    Join Date
    06-27-2012
    Location
    Kuala Lumpur, Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: copy existing code for another sheet

    Quote Originally Posted by Richard Buttrey View Post
    In that case upload the workbook in question as requested and add some notes explaining precisely what you expect to happen with reference to specific cells/sheets.
    uploaded in question.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: copy existing code for another sheet

    Just add another case to the Select Case statement in the Get Information procedure. e.g

    Case "EFF"
    SheetType = 'new sheet name
    OMRType = "OM3" ' or whatever

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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