UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Subtration Date Using Vba, Office 2013    
 
   
kenwood1
post Apr 27 2019, 03:42 AM
Post#1



Posts: 503
Joined: 11-July 09



Hello all,

I have a columnA with a Long serie number and a columnC with date. I would like when columnA if Row for example A3 & A4 has the same serie number, so this will make a subtraction and the result put in column H same row. Below I have a small macro but it did not work.

I am appreciated for any help.


Dim i As Integer, Result As String, Cell As String, ShtRaw As Worksheet

Dim dTheDate As Date

dTheDate = #10.12.2012#

Range("C1:C500").Value = dTheDate


Set ShtRaw = Sheets("Labo")

For i = 1 To 5000

Cell = Cells(i, 1).Value


If ShtRaw.Cells(i, 1) = ShtRaw.Cells(i - 1, 1) Then

dTheDate = Cells(i, 3) - Cells(i, 3)


End If

Cells(i, 8) = dTheDate

Next i



Thanks for all.

Attached File(s)
Attached File  Date.png ( 124.65K )Number of downloads: 1
 
Go to the top of the page
 
kenwood1
post Apr 27 2019, 05:32 AM
Post#2



Posts: 503
Joined: 11-July 09



I think, I found it. Thanks for all

Dim nRowId As Integer

For nRowId = 2 To 100


If Worksheets("Second-Repair").Cells(nRowId, 1) = Worksheets("Second-Repair").Cells(nRowId + 1, 1) Then

Worksheets("Second-Repair").Cells(nRowId + 1, 8) = DateDiff("d", Worksheets("Second-Repair").Cells(nRowId, 3), Worksheets("Second-Repair").Cells(nRowId + 1, 3))

End If


Next nRowId
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    17th June 2019 - 10:35 PM