jamescooper
Well-known Member
- Joined
- Sep 8, 2014
- Messages
- 840
Hello,
I have the following code which starts with an input box that asks you to enter a period (which happens to be 4 digits long).
If this is not in the list "Items" then it will ask you for it again. If this is entered correctly then it will take you to a 2nd input box which asks you for a date in the format "yyyy-mm-dd". How would I put code, say Items2 which linked to a spreadsheet and if it was 1710 and the date 2017-08-20 was in a column B as below, then proceed, but if I entered 2017-08-23 following an entry of 1710, it would ask you for another date?
I hope the above is clear. Many thanks in advance.
1710 2017-08-20
1710 2017-08-21
1710 2017-08-22
1711 2017-08-23
I have the following code which starts with an input box that asks you to enter a period (which happens to be 4 digits long).
If this is not in the list "Items" then it will ask you for it again. If this is entered correctly then it will take you to a 2nd input box which asks you for a date in the format "yyyy-mm-dd". How would I put code, say Items2 which linked to a spreadsheet and if it was 1710 and the date 2017-08-20 was in a column B as below, then proceed, but if I entered 2017-08-23 following an entry of 1710, it would ask you for another date?
I hope the above is clear. Many thanks in advance.
1710 2017-08-20
1710 2017-08-21
1710 2017-08-22
1711 2017-08-23
Code:
Sub Clean_Data()
Dim myValue As Variant
Dim myValue2 As Variant
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim FP As String, FN As String
Dim Found As Boolean
Dim z As Byte
Dim Items() As String
Items = Split("1710,1711,1712,1713,1801,1802,1803,1804,1805,1806,1807,1808,1809,1810,1811,1812,1813,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2101,2102,2103,2104,2105,2106,2107,2108,2109,2110,2111,2112,2113", ",")
Found = False
Do
myValue = InputBox("Enter the period, e.g. 1804")
If StrPtr(myValue) = 0 Then Exit Sub
For z = LBound(Items) To UBound(Items)
If myValue = Items(z) Then Found = True
Next
Loop While Not Found
Dim NoFile As Boolean
NoFiles = False
If myValue = "" Then
Exit Sub
Else
myValue2 = InputBox("Enter the date you wish to clean the data in format yyyy-mm-dd e.g. 2017-06-28")
If myValue2 = "" Then
Exit Sub
Else