+ Reply to Thread
Results 1 to 12 of 12

How to modify a cell based in a value of another cell in a different column

  1. #1
    Registered User
    Join Date
    03-07-2020
    Location
    Los Angeles, California
    MS-Off Ver
    2010
    Posts
    12

    How to modify a cell based in a value of another cell in a different column

    Hello,
    I am looking for a vba code to modify Colum "F" row (which ever has the value 'CANCELADA' in Colum "Q".
    Attached is the sample spreadsheet.

    Thank you.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: How to modify a cell based in a value of another cell in a different column

    How about filtering row 7 and below? and then select in column Q "CANCELADA"
    no need for VBA
    B/R
    Erwin
    I started learning VBA because I was lazy ...
    Still developing.... being more lazy...

  3. #3
    Registered User
    Join Date
    03-07-2020
    Location
    Los Angeles, California
    MS-Off Ver
    2010
    Posts
    12
    Quote Originally Posted by Eastw00d View Post
    How about filtering row 7 and below? and then select in column Q "CANCELADA"
    no need for VBA
    B/R
    Erwin
    Erwin,
    What I would like to happen is that when the option “CANCELADA” is picked on column “Q” column “F” same row as “Q” the value changes to ‘0’ automatically.
    Thank you.

  4. #4
    Registered User
    Join Date
    03-07-2020
    Location
    Los Angeles, California
    MS-Off Ver
    2010
    Posts
    12

    Re: How to modify a cell based in a value of another cell in a different column

    Hello,
    This is the vba code I am trying to use for this, but I can not make it work..Any suggestions?
    I have no idea what i am doing wrong.

    Thank you

    Sub Delete_Rows()
    Dim Firstrow As Long
    Dim Lastrow As Long
    Dim Lrow As Long
    Dim CalcMode As Long
    Dim ViewMode As Long

    With Application
    CalcMode = .Calculation
    .Calculation = xlCalculationManual
    .ScreenUpdating = False
    End With

    'I use the ActiveSheet

    With ActiveSheet

    'I select the sheet so we can change the window view
    .Select

    'If you are in Page Break Preview Or Page Layout view go
    'back to normal view, I do this for speed
    ViewMode = ActiveWindow.View
    ActiveWindow.View = xlNormalView

    'Turn off Page Breaks, I do this for speed
    .DisplayPageBreaks = False

    'Set the first and last row to loop through
    Firstrow = .UsedRange.Cells(1).Row
    Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row

    'I loop from Lastrow to Firstrow (bottom to top)
    For Lrow = Lastrow To Firstrow Step -1

    'I check the values in the Q column
    With .Cells(Lrow, "Q")

    If Not IsError(.Value) Then

    If .Value = "CANCELADA" Then .Cells(Lrow, "F").Value = 0
    'I am tring to change row "F" and column found in "Q" to '0' if the value found is 'CANCELADA'
    'DOES NOT WORK!! WHAT AM I DOING WRONG!! PLEASE HELP!!!
    End If

    End With

    Next Lrow

    End With

    ActiveWindow.View = ViewMode
    With Application
    .ScreenUpdating = True
    .Calculation = CalcMode
    End With

    End Sub

  5. #5
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: How to modify a cell based in a value of another cell in a different column

    Hi Borntobebad,
    please find attached the file with vba-macro
    B/R
    Erwin
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: How to modify a cell based in a value of another cell in a different column

    Sorry, I did not see until now that you have written also code. Let me know if I can help.
    Erwin

  7. #7
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: How to modify a cell based in a value of another cell in a different column

    with a small adjustment it works:
    leave out the "With"statement:
    Please Login or Register  to view this content.
    B/R
    Erwin

  8. #8
    Registered User
    Join Date
    03-07-2020
    Location
    Los Angeles, California
    MS-Off Ver
    2010
    Posts
    12

    Re: How to modify a cell based in a value of another cell in a different column

    Erwin,
    YOU ARE A GENIUS!!
    Thank you very much....You have no idea how many hours I spent trying to make this work.
    Thank you again!!!!

  9. #9
    Registered User
    Join Date
    03-07-2020
    Location
    Los Angeles, California
    MS-Off Ver
    2010
    Posts
    12

    Re: How to modify a cell based in a value of another cell in a different column

    Thank you very much.
    This works too!!

    Do you recommend to use this vba or the one I wrote with the mod?

  10. #10
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: How to modify a cell based in a value of another cell in a different column

    The short one uses less memory/time, so I would use that one.
    If you want to thank me, please give me some rep.points :-)
    B/R
    Erwin
    Last edited by Eastw00d; 03-07-2020 at 07:41 PM.

  11. #11
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this !


    Two ways :

    • when an entry 'CANCELADA' is made in column Q : it needs a worksheet event procedure …

    • Let's see first an ŕ posteriori procedure just using a beginner level formula,
      paste this VBA demonstration to the Sheet1 worksheet module :

    PHP Code: 
    Sub Demo1()
        
    Dim Rg As Range
        Set Rg 
    Cells(Rows.Count17).End(xlUp)
         If 
    Rg.Column 7 Then
            With Range
    ("Q8"Rg)
                .
    Offset(, -11).Value2 Evaluate("IF(" & .Address "=""CANCELADA"",0," & .Offset(, -11).Address ")")
            
    End With
         End 
    If
        
    Set Rg Nothing
    End Sub 
    ► Do you like it ? ► ► So thanks to click on bottom left star icon « Add Reputation » !

  12. #12
    Registered User
    Join Date
    03-07-2020
    Location
    Los Angeles, California
    MS-Off Ver
    2010
    Posts
    12

    Re: How to modify a cell based in a value of another cell in a different column

    Thank you!!

+ 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] Modify cell values based on listBoxes
    By xPukwe in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-28-2020, 01:53 PM
  2. Replies: 4
    Last Post: 02-14-2017, 06:14 PM
  3. Excel 2003 formula - modify one cell, another cell track the modify date
    By baby0596cw in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 11-06-2014, 12:55 PM
  4. Modify Cell Background Color based on cell content
    By CWDurkin in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-01-2014, 11:57 AM
  5. Modify formulas in range based on cell value
    By podunkus in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 11-17-2013, 09:40 PM
  6. VBA modify value based on conditions of another cell
    By sk8shorty01 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-26-2011, 01:20 PM
  7. Modify many row cell (header) to one column
    By darby in forum Excel General
    Replies: 2
    Last Post: 08-24-2005, 01:05 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