+ Reply to Thread
Results 1 to 8 of 8

applying selected cell as variable for target address

  1. #1
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    applying selected cell as variable for target address

    Right now this macro fills in A8 with the formula =IF(PCInfo[[#This Row],[Main Mark]]="","",A7,0)

    I'm looking to have the cell selected replace $A$8

    Also have A7 replaced with the cell above the selected cell


    HTML Code: 

  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: applying selected cell as variable for target address

    HTML Code: 
    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
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: applying selected cell as variable for target address

    This code did not work...

  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: applying selected cell as variable for target address

    I should have examined your text first. Your IF statement has too many arguments.

    =IF(test for true, output when true, output when false)

    "=IF(PCInfo[[#This Row],[Main Mark]]="","",A7,0)"

    test: PCInfo[[#This Row],[Main Mark]]=""
    true output: ""
    false output: A7
    4th unknown output: 0

    Perhaps you meant:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: applying selected cell as variable for target address

    HTML Code: 
    The code that I posted is working fine for me...

    Here's a screenshot of the logic behind it...

    The issue is not that my code has an error, the issue is that I don't know how to replace the cell values in the code it self

    Hence my original questions

    1)How can I replace the A8 in $A$8 with the value of the select cell? If selected cell is A10 then $A$10 should appear, or at least let the code process that's the cell selected.

    2)How can I replace the A7 with the value of the cell above the selected? If selected cell is A10 then I would like to see A7 turn into A9, or at least have the code process it that way

    The reasoning for this is so that any row in this column can hold the value of the formula applied to it when the cell is blank

  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: applying selected cell as variable for target address

    You don't need that line of code if you want to be able to apply it to any cell selected.

    If you instead want to be able to apply it to a range of cells, you can use the Intersect Method:

    Please Login or Register  to view this content.
    When using SelectionChange and Change Events, I highly recommend adding the following line:
    Please Login or Register  to view this content.
    Which will prevent the procedure from running if you select more than one cell at a time.

    Since 'Target' represents the selected cell, Target.Offset(-1) represents the cell above it.

    Assuming the 0 in your original post is just a typo, we can use the A7 as the False Output of your IF and swap Target.Offset(-1) in its place with some concatenation.

    The following code quits if you select more than one cell, and runs only for cells A2:A10 if you select them.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: applying selected cell as variable for target address

    Thank you for your help

  8. #8
    Registered User
    Join Date
    03-26-2015
    Location
    wisconsin, united states
    MS-Off Ver
    2010
    Posts
    47

    Re: applying selected cell as variable for target address

    Thank you for your help

+ 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] Worksheet_Change - If Target.Address = a cell reference
    By dredre609 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-02-2014, 12:04 PM
  2. [SOLVED] how to set the value of the cell with the reference Target.Address to a specific value?
    By AVM in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-14-2014, 01:53 AM
  3. [SOLVED] Assigning A Cell Address to A Variable, Using A Variable - Error '1003'
    By ch_abs in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-28-2014, 01:36 PM
  4. Set Target.Address to a cell in another sheet
    By justinheadley in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-05-2013, 10:58 AM
  5. [SOLVED] Event Macro to display a selected cell in target cell
    By Jacko2stars in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-06-2012, 08:59 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