+ Reply to Thread
Results 1 to 12 of 12

Problem with defining Range in a With Statement

  1. #1
    Registered User
    Join Date
    11-03-2014
    Location
    Sydney, Australia
    MS-Off Ver
    2010
    Posts
    4

    Problem with defining Range in a With Statement

    New to VBA and I am building reports and with to do things with ROW titles.

    I can get individual statements to Bold cells to work but would be much better code to do using with Statement.

    This works
    Please Login or Register  to view this content.
    I have tried various ways of putting With Range.. statements but none seem to work.

    OutSheet and OutLineNum are declared as Public

    Can someone tell me correct way to do a WITH statement for this.

    Much appreciated
    John
    Last edited by JWellar; 11-06-2014 at 05:38 PM.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Problem with defining Range in a With Statement

    Hi John,

    Welcome to the Forum!

    Maybe:

    Please Login or Register  to view this content.
    Last edited by xladept; 11-06-2014 at 02:29 AM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor Cerbera's Avatar
    Join Date
    07-06-2010
    Location
    Rotorua, New Zealand
    MS-Off Ver
    Excel 2007, 2013, 2016 & 365
    Posts
    137

    Re: Problem with defining Range in a With Statement

    Also for a contiguous range you could use:


    Please Login or Register  to view this content.
    If I've helped please click on *Add Reputation

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Problem with defining Range in a With Statement

    Or
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Registered User
    Join Date
    11-03-2014
    Location
    Sydney, Australia
    MS-Off Ver
    2010
    Posts
    4

    Re: Problem with defining Range in a With Statement

    Tried both above but maybe I am not using the solutions correctly. Below is the whole Subroutine called by the main sub

    Please Login or Register  to view this content.
    Last edited by JWellar; 11-06-2014 at 05:38 PM.

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,199

    Re: Problem with defining Range in a With Statement

    Hi, JWellar,

    please use code-tags around your procedures displayed in both your posts as laid down in Forum Rule #3.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Problem with defining Range in a With Statement

    Tried both above
    There are three. ????
    Last edited by xladept; 11-06-2014 at 02:31 AM.

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,199

    Re: Problem with defining Range in a With Statement

    Hi, JWellar,,

    Your posts do not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    Ciao,
    Holger

  9. #9
    Registered User
    Join Date
    11-03-2014
    Location
    Sydney, Australia
    MS-Off Ver
    2010
    Posts
    4

    Re: Problem with defining Range in a With Statement

    Sorry fixed and understand how to post

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Problem with defining Range in a With Statement

    What did you try?
    Everyone who confuses correlation and causation ends up dead.

  11. #11
    Registered User
    Join Date
    11-03-2014
    Location
    Sydney, Australia
    MS-Off Ver
    2010
    Posts
    4

    Re: Problem with defining Range in a With Statement

    I have tried replacing "OutSheet... = True" lines with both


    Please Login or Register  to view this content.
    and then
    Please Login or Register  to view this content.
    Thanks for any assistance
    John

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Problem with defining Range in a With Statement

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

+ 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. Problem in defining range
    By aganesan99 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-10-2014, 05:04 AM
  2. [SOLVED] Problem defining a variable range to auto sum
    By Excelisdrivingmemad in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 02-03-2013, 11:55 AM
  3. Replies: 5
    Last Post: 12-25-2011, 08:19 AM
  4. Problem defining -some- variables in an IF statement
    By Gordon@work in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-05-2007, 02:51 AM
  5. Syntax problem defining range for pivot table
    By Richard in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-14-2006, 02: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