+ Reply to Thread
Results 1 to 7 of 7

Syntax for visible range between two columns to last row

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,062

    Syntax for visible range between two columns to last row

    I want to color a range between two columns, to the last row. Columns are figured via the macro, but I don't know how to use that info to set the range object.

    Below are the pertinent pieces of my code as it currently exists, with my offending line in red. Any help I can get in straightening this one out is highly appreciated.
    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Syntax for visible range between two columns to last row

    Since you did not show your entire code I will assume there is a With statement indicating the sheet reference. With a little analysis we can observe that your case is 1 to 12 and that your column is sequential and 7 more than MFRmo. The red line that you indicated is flawed in many ways so I rewrote what I think you are trying to accomplish

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,062

    Re: Syntax for visible range between two columns to last row

    Sorry for not showing the whole code; It's pretty long, I'm trimming as I can. We're working on the Activesheet.

    I apprecaite the shortend Select statement. On the definition of Proj, it's actually Column T, so I need to get the range from after Result through column T. I'm starting to work with your syntax to see how that works. I'll post results in a few minutes.

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Syntax for visible range between two columns to last row

    I just noticed that this line will also error

    Please Login or Register  to view this content.
    Change it to this:

    Please Login or Register  to view this content.
    As a side note, are you sure this part is doing what you want it to do?
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,062

    Re: Syntax for visible range between two columns to last row

    Hmm, getting a Run-time 1004 error on the syntax line.

    Also, saw your last post late.

    This line is not erroring:
    Please Login or Register  to view this content.
    And the segment you asked about IS doing what I expect.

    On the "Select" statement, my "Result" was a column Letter, but in your updated code the Result is MFRMO +7, so a column number.
    Last edited by jomili; 04-08-2015 at 12:55 PM.

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Syntax for visible range between two columns to last row

    Since Result is now a numerical value, this line is problematic

    Please Login or Register  to view this content.
    Given arbitrary values Result = 12 and LastRow = 35 The code would be equivalent to this

    Please Login or Register  to view this content.
    See the issue?

    Another thing. Is Proj always column T? If it is there is no need for a variable. Lastly, I do not know why the the line is erroring. It looks ok to me but without an example workbook there is no way to tell what is causing it. Best of luck.

  7. #7
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,062

    Re: Syntax for visible range between two columns to last row

    Thanks Stynkynts.

    Yes, Proj is always T. I've done a rethink, and simplified the issue. My variables are MFRMo and Proj. MFRMo is my last column with expenses; Proj is my first month that I'm making a projection for. So H:MFRmo is my expense range, Proj:S is my Projection range. I determine MFRMo and Proj on a different sheet (my user has to select the month they're making a projeciton for, so I put in a simple formula to calculate my variables based on their selection). My updated code is below. My next task is to figure our the formulas to plug in for calculating my fields, so you might see another post if I run into an issue there. Thanks so much for tackling this one with me.
    Please Login or Register  to view this content.

+ 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. Replies: 1
    Last Post: 02-11-2015, 07:47 AM
  2. Dynamic Range to select only visible columns
    By morangeman in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-07-2014, 12:03 AM
  3. Read Only Visible Columns from a range
    By ravinder_tigh in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-17-2009, 01:37 AM
  4. Resize Visible Rows based only on Visible Columns text
    By Zimbo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-22-2009, 10:55 AM
  5. Set Range of visible Autofilltered columns VBA?
    By Dennis@NoSpam.com in forum Excel General
    Replies: 6
    Last Post: 05-05-2006, 10:40 AM

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