Consulting

Results 1 to 8 of 8

Thread: advanced replace macro

  1. #1

    advanced replace macro

    Hello
    I have a spreadsheet with loads data with times and dates.
    1)Column A cells include time like 15:00:00.
    I would like a macro that replaces the cell with only the minutes.
    e.g 15:00:00 replace with 0, 15:01:00 replace with 01, 15:02:00 replace with 02, and so on.

    2)Column B has dates like 01.02.2008.
    I would like a macro that replace the cell with only the last 2 digits of the year.
    e.g 01.02.2008 replace 08, 05:01:10 replace with 10 and so on.

    Thank you in advance!

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    One can only hope that killbill did the right thing and notified the other forums that the thread has been cross posted elsewhere.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    Sorry guys but honestly I didn't know that it was wrong!

  5. #5
    very basic anyway

    for each cel in range("a:a")
       if isempty(cel) then exit for    ' exit on empty cell
       cel.value = mid(cel.value, 4, 2)
       cel.offset(, 1).value = right(cel.offset(, 1).value, 2)
    next

  6. #6
    Thank you westconn1.And sorry for cross-posting.

  7. #7
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Cross posting suggests that you have little faith in expecting a positive response from this forum. Can I say that those people who contribute to this forum do so on a voluntary basis. and as such their contributions a valued. Whether they are right or wrong is irrelevant, they have tried their best to provide a solution to your issue, and for that you need to be thankful. Please acknowledge others when gaining an advantage ( knowledge). There are others who have gained a reputation for serial cross posters and they gain very little response where ever they post
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  8. #8
    I am grateful.
    I did not know.Sorry for that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •