+ Reply to Thread
Results 1 to 13 of 13

how to set the value of the cell with the reference Target.Address to a specific value?

  1. #1
    Registered User
    Join Date
    06-10-2014
    Posts
    43

    how to set the value of the cell with the reference Target.Address to a specific value?

    Target.Value = 100 does not seem to work, either. pls, help!

  2. #2
    Forum Contributor
    Join Date
    12-27-2012
    Location
    cebu, Philippines
    MS-Off Ver
    Excel 2016
    Posts
    210

    Re: how to set the value of the cell with the reference Target.Address to a specific value

    if i want cell A1 in sheet1 to have a value of 100, i would type in

    Please Login or Register  to view this content.
    don't worry, there's a lot of people that are far more confused than you
    but if you liked what i suggested. Click for me the "Add Reputation" - that way, we'd be both happy.

  3. #3
    Registered User
    Join Date
    06-10-2014
    Posts
    43

    Re: how to set the value of the cell with the reference Target.Address to a specific value

    ag273: I cannot use what you suggested as I do not know the cell's reference. It changes. I have a combobox popping up in different cells and so I have to find a workaround. This is why my question was about setting a value to the cell with the reference Target.Address

  4. #4
    Forum Contributor
    Join Date
    12-27-2012
    Location
    cebu, Philippines
    MS-Off Ver
    Excel 2016
    Posts
    210

    Re: how to set the value of the cell with the reference Target.Address to a specific value

    if its the currently selected cell you're referring to, you can use the "activecell" range

    so example, if I have my cursor on cell B3 (regardless of the worksheet) and i want that cell to get a value of 100, then i would write:
    Please Login or Register  to view this content.
    such statement can add the value of 100 to what ever cell the cursor is on.

  5. #5
    Registered User
    Join Date
    06-10-2014
    Posts
    43

    Re: how to set the value of the cell with the reference Target.Address to a specific value

    ag273n: this does not seem to work- maybe because there is no active cell (as a guess) - while it is a combo box that is active (pardon my dilettante guesses)

  6. #6
    Forum Contributor
    Join Date
    12-27-2012
    Location
    cebu, Philippines
    MS-Off Ver
    Excel 2016
    Posts
    210

    Re: how to set the value of the cell with the reference Target.Address to a specific value

    wait, i just recalled that statement you ask of is found in the worksheet selection change sub...
    like this:
    Please Login or Register  to view this content.
    now that code worked on me... every worksheet that has that code automatically puts 100 into the selected cell. Are you trying to do this in a single worksheet?

  7. #7
    Registered User
    Join Date
    06-10-2014
    Posts
    43

    Re: how to set the value of the cell with the reference Target.Address to a specific value

    ag273n:

    I have to write something like the below

    Private Sub ComboBoxCode_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    'Hide combo box and move to next cell on Enter and Tab
    Select Case KeyCode
    Case 9
    Target.Value = LookUpValue
    ActiveCell.Offset(0, 1).Activate
    'LookUpWord = ""
    'ComboBoxCode.Visible = False
    Case 13
    Target.Value = LookUpValue
    ActiveCell.Offset(1, 0).Activate
    'LookUpWord = ""
    'ComboBoxCode.Visible = False
    Case Else
    'do nothing
    End Select
    End Sub

    But this does not run correctly - something is wrong with Target.Value = LookUpValue

  8. #8
    Registered User
    Join Date
    06-10-2014
    Posts
    43

    Re: how to set the value of the cell with the reference Target.Address to a specific value

    the above code meant to put the value of LookUpValue (a name) into the cell where ComboBox is before another cell gets active and the combo box stops being active

  9. #9
    Forum Contributor
    Join Date
    12-27-2012
    Location
    cebu, Philippines
    MS-Off Ver
    Excel 2016
    Posts
    210

    Re: how to set the value of the cell with the reference Target.Address to a specific value

    the above code you have will never work, the sub doesnt accept a target variable or a range variable,

    at the very bottom of the code, you'll need to add a line that will refer to a cell still so the code will add it on the cell
    the target.value method will only work on subs like this:
    Please Login or Register  to view this content.
    notice it says "target as Range", the sub recognizes that its accepting a range

    can you attach a sample workbook so i can take a look at it?

  10. #10
    Registered User
    Join Date
    06-10-2014
    Posts
    43

    Re: how to set the value of the cell with the reference Target.Address to a specific value

    how to attach a file (I only know how to attach a file when starting a thread) - now there is not "attach" icon here

  11. #11
    Forum Contributor
    Join Date
    12-27-2012
    Location
    cebu, Philippines
    MS-Off Ver
    Excel 2016
    Posts
    210

    Re: how to set the value of the cell with the reference Target.Address to a specific value

    at the bottom where you type for a reply, it says "Go Advanced" click that, then below again, you will see "Manage Attachment"

  12. #12
    Registered User
    Join Date
    06-10-2014
    Posts
    43

    Re: how to set the value of the cell with the reference Target.Address to a specific value

    click any cell in column L (lower than line 11) of tab Transaction - a combo box should pop up
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    06-10-2014
    Posts
    43

    Re: how to set the value of the cell with the reference Target.Address to a specific value

    oh, Target.Value = ComboBoxCode.Text appears to work!

+ 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: 3
    Last Post: 10-29-2013, 12:06 AM
  2. 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
  3. Replies: 3
    Last Post: 02-14-2012, 10:37 AM
  4. Convert text address to cell reference address
    By shaod in forum Excel General
    Replies: 1
    Last Post: 12-23-2011, 01:37 AM
  5. [SOLVED] Reference to content AND formating of target cell
    By 0-0 Wai Wai ^-^ in forum Excel General
    Replies: 3
    Last Post: 09-08-2005, 06:05 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