+ Reply to Thread
Results 1 to 8 of 8

ByVal Target as Range to Last Row

  1. #1
    Registered User
    Join Date
    09-11-2015
    Location
    California, usa
    MS-Off Ver
    2010
    Posts
    44

    ByVal Target as Range to Last Row

    Hello All,

    I am having trouble with the falling code to go to last row. Here is my code so far:

    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim LR As Long
    LR = Range("J" & Rows.Count).End(xlUp).Row

    If Target.Address(False, False) = "K21" Then
    Application.EnableEvents = False
    If Target.Value > 0 Then
    Range("K22:K" & LR).FormulaR1C1 = Target.Value
    Else
    Range("K22:K" & LR).ClearContents
    End If
    Application.EnableEvents = True
    End If
    End Sub

    Any help would be greatly appreciated.

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: ByVal Target as Range to Last Row

    Edit: OP added tags

    Are you intentionally detecting lastrow in J, and then outputting in K?

    Please Login or Register  to view this content.
    Last edited by daffodil11; 10-09-2015 at 05:01 PM.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Registered User
    Join Date
    09-11-2015
    Location
    California, usa
    MS-Off Ver
    2010
    Posts
    44

    Re: ByVal Target as Range to Last Row

    My apologies. Noted. Yes, I am intentionally detecting lastrow in J and out putting in K.
    Please Login or Register  to view this content.

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: ByVal Target as Range to Last Row

    All of the examples I've put this in ran just fine.

    Can you fabricate an example to show me what isn't happening on your end?

  5. #5
    Registered User
    Join Date
    09-11-2015
    Location
    California, usa
    MS-Off Ver
    2010
    Posts
    44

    Re: ByVal Target as Range to Last Row

    Yes, Please see attached example.
    Attached Files Attached Files

  6. #6
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: ByVal Target as Range to Last Row

    I type in 10, it copies from K22 to K36. If I type in -10 it deletes it.

    Is this not correct?

  7. #7
    Registered User
    Join Date
    09-11-2015
    Location
    California, usa
    MS-Off Ver
    2010
    Posts
    44

    Re: ByVal Target as Range to Last Row

    Correct. Thank you for assisting. I caught my error. I will mark as solved.

  8. #8
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: ByVal Target as Range to Last Row

    No problem. Sometimes all it takes is a fresh set of eyes.

+ 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] byval target as range
    By mgblair in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-18-2015, 07:28 PM
  2. Replies: 5
    Last Post: 12-16-2014, 05:47 PM
  3. [SOLVED] Change(ByVal Target As Range) does not work when Target value changes
    By LeonvL in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 01-07-2013, 06:59 PM
  4. [SOLVED] Worksheet_Change(ByVal Target As Range) - set to only update when 3 target cells changed?
    By trillium in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-07-2012, 06:40 PM
  5. Worksheet_CHange (ByVal Target as Range) when target is formula cell
    By coasterman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2012, 07:00 PM
  6. Ranges:Target in Worksheet_SelectionChange(ByVal Target As Range)
    By Kevin McCartney in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-15-2005, 09:06 AM
  7. [SOLVED] ByVal Target As Range
    By monir in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-12-2005, 12:06 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