+ Reply to Thread
Results 1 to 2 of 2

Updating Date based on replaced Values Excel VBA Question

  1. #1
    Registered User
    Join Date
    09-04-2013
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    5

    Updating Date based on replaced Values Excel VBA Question

    Hi everyone,

    I am a new Excel VBA user (Today is the first day I have tried making any macros ever!)

    I would like to write a macro which will update a date to todays date if the corresponding number is replaced.

    Here are 4 rows of the sheet I am trying to update:

    4190-AR FRAME ASSY, FR DR WDO, RH 100011-0281-R00 80200 5AA0A 6/5/13 P42M
    4190-AL FRAME ASSY, FR DR WDO, LH 100012-0273-RAC 80201 5AA0A 6/5/13 P42M
    4190-USS1 FRAME SUB-ASSY, FR DR WDO, RH 101011-0051-RAC 80210 5AA0A 3/5/13 P42M
    4190-USS2 FRAME SUB-ASSY, FR DR WDO, LH 101012-0063-RAA 80211 5AA0A 3/5/13 P42M


    I have figured out how to replace the numbers (prob a 'bulky' code, but it works!)


    Sub UpdateRevision()

    'Assuming the numbers start in C4
    Range("C4").Select

    'Finds last row with data in it starting from C65536 (Last row in Excel)
    Range(Selection, Range("C65536").End(xlUp)).Select

    'Counts number of row from C4 to found last row
    RowCounter = Selection.Count

    'Updates Part Number Revision Level

    'Updates RAB to RAC
    For i = 4 To RowCounter + 1
    Range("C" & i).Select
    ActiveCell.Replace What:="RAB", Replacement:="RAC", LookAt:=xlPart, _
    SearchOrder:=xlByColumns, MatchCase:=False
    Next i

    'Updates RAA to RAB
    For i = 4 To RowCounter + 1
    Range("C" & i).Select
    ActiveCell.Replace What:="RAA", Replacement:="RAB", LookAt:=xlPart, _
    SearchOrder:=xlByColumns, MatchCase:=False
    Next i

    'Updates R00 to RAA
    For i = 4 To RowCounter + 1
    Range("C" & i).Select
    ActiveCell.Replace What:="R00", Replacement:="RAA", LookAt:=xlPart, _
    SearchOrder:=xlByColumns, MatchCase:=False
    Next i

    End Sub



    Now Id like to Update the date when the part number is replaced. For example

    If 100011-0281-R00 changes to 100011-0281-RAA, then the Date would change from 6/5/13 to 9/4/13 (todays date)

    I am thinking that it might have to be some sort of IF THEN Loop? But like I said this is literally my first go at making a macro, and I havent quite figured those out yet.

    but the basic 'structure' might go something like this:?

    IF (part number is updated)
    THEN (change date to today)
    ELSEIF (Part number is the same)
    THEN (Dont change Date)

    Anyways, any help would be appreciated. And Im not looking for just a simple code - if you could provide comments that actually explain what the code is doing, that would be great as I am trying to learn for my job.

    THANKS!!!

    - Ryan

  2. #2
    Registered User
    Join Date
    09-04-2013
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Updating Date based on replaced Values Excel VBA Question

    Sorry for the format issues btw - I tried to make it look nice but it isnt seem to be cooperating with me.

+ 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: 08-28-2013, 09:26 AM
  2. Having problems updating a workbook based on values from many other workbooks
    By gibson2503 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-19-2013, 03:50 PM
  3. Replies: 0
    Last Post: 04-25-2012, 05:42 PM
  4. updating date based on another cells value
    By tattooguy21 in forum Excel General
    Replies: 13
    Last Post: 04-18-2010, 04:55 PM
  5. updating a workbook based on previous values
    By simora in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-25-2005, 03:00 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