+ Reply to Thread
Results 1 to 7 of 7

Syntax for visible range between two columns to last row

Hybrid View

  1. #1
    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

    MFRmo = Wb.Sheets("Start Tab").Range("G2").Value 'what's our MFR month?
    
            Select Case MFRmo
                Case 1 To 12
                    Result = MFRmo + 7 'this will give a numerical value which will accurately represent the column number
            End Select
            
            'This section is okay.  I would like to see the range defined a little bit more.
            Set RngFound = .Cells.Find(What:="Projected")
            If Not RngFound Is Nothing Then
                Proj = RngFound.Column
            End If
    
            'Color our expense headings Peach
            .Range("A1").AutoFilter Field:=3, Criteria1:="=Category"
            .Range("H1:" & Result & LastRow).SpecialCells(xlCellTypeVisible).Interior.Color = RGB(252, 213, 180)
    Stop
            'Color our projection headings Blue
            '.Range(.Range(Result & Rows(1)).Offset(0, 1), .Columns(Proj)).SpecialCells(xlCellTypeVisible).Interior.Color = RGB(183, 222, 232)
            .Range(.Cells(1, Result), .Cells(.Cells(Rows.Count, Proj).End(xlUp).Row, Proj)).SpecialCells(xlCellTypeVisible).Interior.Color = RGB(183, 222, 232)
            
            'Take off the autofilter
            .AutoFilterMode = False

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

    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:
    .Range("H1:" & Result & LastRow).SpecialCells(xlCellTypeVisible).Interior.Color = RGB(252, 213, 180)
    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.

+ 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. [SOLVED] 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