+ Reply to Thread
Results 1 to 5 of 5

with statement

  1. #1
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    with statement

    Hi Guys,

    I wonder if someone could take the time to help..

    I would like to amend this code slightly by forcing it to perform the exact same function on an additional tab called Forecast.

    So where the code says With Worksheets("Drill Down") I want it to say With Worksheets("Drill Down") and worksheet Forecast, however I am not having much success!

    Maybe it's something like

    Worksheets("Drill Down").select
    WorkSheets("Forecast").select

    Thanks for looking

    Please Login or Register  to view this content.
    Last edited by Blake 7; 02-27-2014 at 05:04 PM.
    Blake 7

    If your question has been answered, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

    If any member's response has helped to solve your problem, please consider using the scales icon on the top right of their post to show your appreciation.

    http://failblog.org/

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,712

    Re: with statement

    Add the following lines of code to your Dimensions

    Please Login or Register  to view this content.
    Replace the With Statement with
    Please Login or Register  to view this content.
    Replace the End With Statement with
    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,846

    Re: with statement

    The minimal change to make to do this operation on two different sheets is to add the worksheet as an argument to your sub, then call it twice. See code highlighted in red. Did I understand the question?

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  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,863

    Re: with statement

    may be try:
    Please Login or Register  to view this content.
    edit: almost the same way ;-) but as always slightly different way to skin the cat.
    Notice other type of argument, other way to call procedure with argument and my doubts about serching for value of y - shall it be always taken from Drill Down sheet? Can imagine that it shall do this way. Or shall it be determined as other value for Forecatst sheet - also pausible.
    Last edited by Kaper; 02-27-2014 at 04:56 PM.
    Best Regards,

    Kaper

  5. #5
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: with statement

    Awesome - many thanks guys for taking the time to help. I appreciate the different solutions! Solved!

    Jeff, you did understand!! good to hear from you.

+ 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] If statement that will look among multiple criteria and generate a statement
    By liz5818 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-01-2013, 04:12 PM
  2. VBA Compile Error : line number or label or statement or end of statement
    By excellearner121 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2013, 06:41 PM
  3. Replies: 4
    Last Post: 06-01-2012, 10:05 AM
  4. Replies: 4
    Last Post: 05-16-2012, 05:33 PM
  5. [SOLVED] Utilize a Select Case Statement in Target Intersect Statement
    By max57 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2009, 08:55 PM

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