+ Reply to Thread
Results 1 to 6 of 6

VBA picked the wrong column when specifying Range("B" & lastrow)

  1. #1
    Forum Contributor
    Join Date
    06-19-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Office365
    Posts
    273

    VBA picked the wrong column when specifying Range("B" & lastrow)

    Hello,

    I encountered a very strange thing today.

    I have a worksheet change event that updates a financial statement structure on a tab named "Model"

    I have a line in the code that simply is:
    Please Login or Register  to view this content.
    but when this code is run, the value somehow ended up in column C instead of B, in the correct row.

    I literally had to add offset(,-1) to get it back to column B.

    does anyone know why this has happened?

    thanks so much
    Last edited by lynnsong986; 10-03-2020 at 10:54 PM.

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: VBA picked the wrong column when specifying Range("B" & lastrow)

    And the rest of the code is..........

  3. #3
    Forum Contributor
    Join Date
    06-19-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Office365
    Posts
    273

    Re: VBA picked the wrong column when specifying Range("B" & lastrow)

    Please Login or Register  to view this content.
    this is the part that is relevant, the event code is quite lengthy. thanks for taking a look!

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: VBA picked the wrong column when specifying Range("B" & lastrow)

    It's because you are using that with range B
    Please Login or Register  to view this content.
    this is effectively
    Please Login or Register  to view this content.
    which is column C

  5. #5
    Forum Contributor
    Join Date
    06-19-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Office365
    Posts
    273

    Re: VBA picked the wrong column when specifying Range("B" & lastrow)

    oh thank you soooo much!! I totally forgot how that part works!

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: VBA picked the wrong column when specifying Range("B" & lastrow)

    Glad to help & thanks for the feedback.

+ 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] Need help modifying multiple range code to include LastRow ("B2:B10",..) -> ("B2:B" & LR.)
    By sureng20 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-09-2017, 09:31 AM
  2. "Error" or "Disallow" Entries If Data Entered in Wrong Cell
    By sage.tx in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-12-2017, 12:20 PM
  3. Replies: 4
    Last Post: 06-11-2017, 02:03 PM
  4. [SOLVED] Column X-Ref list - Sheet1 Col A "pages", Col B:FL "Req" to Sheet2 ColA "req", ColB "page"
    By excel-card-pulled in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-07-2017, 09:30 AM
  5. [SOLVED] If there is any text in column "A$" on "sheet1" then move cell to column "A$" on "sheet2"
    By ckgeary in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-27-2013, 08:28 PM
  6. Replies: 3
    Last Post: 04-14-2013, 11:53 PM
  7. How to transpose data into range ("A1:G" & lastrow)
    By jasondu in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-06-2012, 10:39 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