+ Reply to Thread
Results 1 to 3 of 3

Defining the last column

Hybrid View

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

    Defining the last column

    I can't figure it. For over a year I've been using this line of code with no problems:
    Lastcol = Sheets("FY12 Running History").Range("A3:A14").End(xlToRight).Offset(0, 1).Column
    Now I've just added a new sheet for FY13, and changed the code to
    Lastcol = Sheets("FY13 Running History").Range("A3:A14").End(xlToRight).Offset(0, 1).Column
    I've verified that name is right by copying the tab name and pasting it into my code. But when I try to run my code, I get a run-timm 1004, Application Defined or Object Defined error. I try it on my FY12 sheet, it works fine, on my FY13 it bombs. After that happend and I couldn't figure it, I deleted my F13, copied my FY12, changed FY12 to FY13, and it bombed again. What gives?

    Help, please!

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Defining the last column

    try it
    Lastcol = Sheets("FY13 Running History").Range("A3:A14").CurrentRegion.Columns.Count + 1

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Defining the last column

    if your cells in row 3 from column B are blank then end(xltoright) will take you to the last column and you then try and offset one to the right
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ 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