Hello, I am new and was hoping someone could help me.
I have this awesome code and want to add some code to extract new updates from Sheet2 col "T", based on col "F" ---> Sheet1 Col "C" & "A" respectively.
So,
Sheet2 col "T", => Sheet1 Col "C"
Sheet2 col "F" => Sheet1 Col "A"
Thank you!!
I have this awesome code and want to add some code to extract new updates from Sheet2 col "T", based on col "F" ---> Sheet1 Col "C" & "A" respectively.
So,
Sheet2 col "T", => Sheet1 Col "C"
Sheet2 col "F" => Sheet1 Col "A"
Thank you!!
VBA Code:
Sub test3()
Dim fullstr As String
With Worksheets("Sheet2")
lastup = .Cells(Rows.Count, "F").End(xlUp).Row ' find last row in column F of sheet 2
updt = Range(.Cells(1, 1), .Cells(lastup, 24)) ' pick columns A to X and all rows in sheet 2
' new mapping G is now F column 6
' H is now X column 24
'I is now T column 20 Date is assumed to be all the characters up to the first space
End With
Worksheets("Sheet1").Select ' lots of people say don't use select but doing it once is quick and easy!!
lastmast = Cells(Rows.Count, "A").End(xlUp).Row
mastarr = Range(Cells(1, 1), Cells(lastmast, 4))
For i = 2 To lastmast
For j = 2 To lastup
If mastarr(i, 1) = updt(j, 6) Then ' Column F
mastarr(i, 3) = updt(j, 24) ' update status for all rows
' convert update status to upper case for comparison
sts = StrConv(updt(j, 24), vbUpperCase)
If sts = "DELIVERED" Or sts = "RECEIVED" Then
fullstr = updt(j, 20) ' Column T
startstr = -1
endstr = Len(fullstr)
For kk = 1 To Len(fullstr)
digt = Mid(fullstr, kk, 1)
If IsNumeric(digt) And startstr < 0 Then ' check for the first number in the string
startstr = kk ' set this to start of the string
End If
digasc = Asc(digt) ' convert the curent character to ascii
If startstr > 0 And (digasc > 57 Or digasc < 47) Then ' this checks whether the digit is a number or /
endstr = kk ' set then end of the string as the first character which isn't a number or a slash
Exit For
End If
Next kk
If startstr > 0 Then
dt = Mid(fullstr, startstr, endstr - startstr + 1)
mastarr(i, 4) = dt
End If
End If
End If
Next j
Next i
Range(Cells(1, 1), Cells(lastmast, 4)) = mastarr
End Sub