+ Reply to Thread
Results 1 to 6 of 6

Change cell value based on active cell

Hybrid View

  1. #1
    Registered User
    Join Date
    05-30-2012
    Location
    Luxembourg
    MS-Off Ver
    Excel 2010
    Posts
    3

    Change cell value based on active cell

    I have 2 columns G and I n which on each row a list exist to choose a value.
    I would like that when I choose No in my list box of column G that I is changed into value 6.
    And of course this would happen on each row where I change the value of column I.
    I'm completely lost in the dark of macro writing unfortunately.
    any help is welcome.

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Change cell value based on active cell

    What you need is a bit of VBA code that is automatically triggered as soon as you make a change to the specific worksheet. Excel supports this via events which can be monitored at workbook or specific worksheet level. You will need to copy & paste the code provided below into the module that is associated to the worksheet you are working with

    Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
         If Target.Column = 7 Then
              If Target.Value = "No" Then
                   ActiveSheet.Cells(Target.Row, "I").Value = 6
              End If
         End If
    End Sub
    If you like my contribution click the star icon!

  3. #3
    Registered User
    Join Date
    05-30-2012
    Location
    Luxembourg
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Change cell value based on active cell

    Thanks for the reply.
    Just a question, why is target.column a number value and in target row a letter value?
    My first thought would be the opposite no?

  4. #4
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Change cell value based on active cell

    Target is a range object and has many properties amongst which are value, row, column etc

  5. #5
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Change cell value based on active cell

    The letter you refer to is a parameter of the Cells object and not the Target object. The instruction means a cell on the same row as the target cell in column I

  6. #6
    Registered User
    Join Date
    05-30-2012
    Location
    Luxembourg
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Change cell value based on active cell

    THanks for the help and information

+ 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