+ Reply to Thread
Results 1 to 8 of 8

Activate Worksheet Using Concatenated Strings for Name

  1. #1
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Activate Worksheet Using Concatenated Strings for Name

    Hi all,

    I am trying to create a macro to cycle through four worksheets and, if a date in a column is within a specified range, copy various cells in that record and paste them in another sheet in different workbook. For example, if column K >= 01-Jan-2012 and <= 31-Mar-2012, copy columns A, F, G, P, T and W and paste them in columns A, F, D, B, E and C of the other specified sheet.

    The four sheets are named in a ABC2011, XYZ2011, ABC2012 and XYZ2012. Each year, two the names end with the previous year and the other two end with the current year.

    I have not been able to activate the sheet (using strings to identify it).

    Here is my code, so far:

    Please Login or Register  to view this content.
    Can someone help me fix it, please?

    Thank you,
    Gos-C
    Using Excel 2010 & Windows 10
    "It is better to be prepared for an opportunity and not have one than to have an opportunity and not be prepared."

  2. #2
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: Activate Worksheet Using Concatenated Strings for Name

    edit: Read your post wrong on what you wanted.

  3. #3
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Re: Activate Worksheet Using Concatenated Strings for Name

    Hi 111StepsAhead,

    Thank you very much for your quick response.

    I want to use variables for the sheets names so that I won't have to change them in the macro each year.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Activate Worksheet Using Concatenated Strings for Name

    I would think you could set the wks1 variable name like so:

    Please Login or Register  to view this content.
    You can get last year with Year(Date)-1.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Re: Activate Worksheet Using Concatenated Strings for Name

    I tried that but it didn't work.

  6. #6
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Re: Activate Worksheet Using Concatenated Strings for Name

    Hi all,

    I got it to work!

    I used:

    Please Login or Register  to view this content.
    Thank you,
    Gos-C

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Activate Worksheet Using Concatenated Strings for Name

    If that takes care of your need, please click Thread Tools above your first post and mark this thread as SOLVED.

  8. #8
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Re: Activate Worksheet Using Concatenated Strings for Name

    Last edited by Gos-C; 04-18-2012 at 11:39 AM. Reason: Moved follow-up request to a new thread as the title was no longer correct.

+ 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