You are here:

Excel/Transfering without duplicating

Advertisement


Question
Good day.  I have a sheet that in column P tells me when a piece of equipment is "Running" or "DOWN".  Once the machine goes from running to down, in column Q I have a timestamp that tells me when it went down.  Once down I have a button on top that I hit and it transferes any DOWN over to another sheet called "LOG".  The only problem Iam having with this is that I have to update this sheet alot during the day and whenever I hit the transfer button it transfers everything again, even the ones that have already been transfered earlier.  Is there a way to get it to recognise the timestamp or something so that it will not duplicate unless the time has changed.  Here is what Iam using right now.
   Application.ScreenUpdating = False
If Not Intersect(Target, Range("P:P")) Is Nothing Then
   If Target.Value = "WELL DOWN" Then
       Range("B" & Target.Row, "BH" & Target.Row).Copy
       Sheets("LOG").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
   End If
End If

Application.CutCopyMode = False
Application.ScreenUpdating = True
Any help would be greatly appreciated.
Thanks in advance
RR

Answer
At the moment, the macro is doing a copy and paste based only on the target.value - I think it would need to do two other checks - firstly, a countif to determine if the line exists on the LOG sheet - if it doesn't it would copy it.  If it DOES, then it would need to do a lookup to get the timestamp and if that is the same do nothing, otherwise either copy or update the existing entry.

Let me know if you need any help with coding any of the above - for both my suggestions, application.worksheetfunction would do it.
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Aidan Heritage

Expertise

I have provided first hand support since `95 for Microsoft Office majoring in Word and Excel - support for all versions from 2 onwards. I'm based in the UK, so please allow for time differences when asking me questions from other parts of the world!

Experience

My background is in the insurance industry and call centre areas, but have been called upon to provide many varied solutions.

Education/Credentials
I'm educated to UK A level standard, but as I left school some 30 years ago that is rather irrelevent - university of life has provided more of a background!

©2016 About.com. All rights reserved.