+ Reply to Thread
Results 1 to 8 of 8

Macro to update cell (should be easy)

  1. #1
    Registered User
    Join Date
    04-04-2013
    Location
    Miami, Florida
    MS-Off Ver
    Excel 2010
    Posts
    5

    Macro to update cell (should be easy)

    Hi There,

    I need a macro to update columns B4:B6 depending on cells E12:E14. Cells B4:B6 would ONLY be updated if the corresponding 'pet' exists in A12:A14.

    I've attached my example. This sounds VERY simple to do, I'm just not sure what functions or coding I need.

    Thanks!!

    Update Macro Help.xls

  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Macro to update cell (should be easy)

    I think this is what you need. Paste this code in the sheet module (see attached for working model).
    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro to update cell (should be easy)

    Hi Leinad,

    Here's a short routine for the update part:

    Please Login or Register  to view this content.
    Directions for running the routine(s) just supplied

    Copy the code to the clipboard

    Press ALT + F11 to open the Visual Basic Editor.

    Open a macro-enabled Workbook or save your Workbook As Macro-Enabled

    Select “Module” from the Insert menu

    Type "Option Explicit" then paste the code under it

    With the cursor between Sub and End Sub press F5 (F8 to Single Step)

    OR

    Press ALT + Q to close the code window.

    Press ALT + F8 then double click on the macro name
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Macro to update cell (should be easy)

    Wait, I may have misunderstood the problem. The solution I posted updates B4 when C12 is updated. But I think that's not what you're looking for.

  5. #5
    Registered User
    Join Date
    04-04-2013
    Location
    Miami, Florida
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Macro to update cell (should be easy)

    Oh my goodness xladept! Amazing - exactly what I asked for! Now - I need to figure out how to change the 'directory' of my list to another location . At least I have the codes to go by and start to understand what they mean.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro to update cell (should be easy)

    Great! You're welcome! Glad that you're "getting" it!

  7. #7
    Registered User
    Join Date
    04-04-2013
    Location
    Miami, Florida
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Macro to update cell (should be easy)

    Actually, how would I modify this code to have the updates occur in a different sheet. Do I need to put "Worksheet!" before the ranges?

    Thanks!

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro to update cell (should be easy)

    Hi Leinad,

    Please Login or Register  to view this content.
    And, there are other ways to do it: if you just wanted every sheet in the book - you could use the For Each...Next:

    Please Login or Register  to view this content.
    Last edited by xladept; 04-05-2013 at 04:14 PM.

+ 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