Hello,
I need a macro that inserts dates into cells based on values from cells in another column.
Here's what my spreadsheet looks like:
I need to fill in the START_DATE column with start dates in format MM/DD/YYYY. The dates are based on the part of the string of numbers and letters from the CLASS_NO column that appear as a date. For example, in the first row you see "06052022_GST_402" and the first string of numbers are a date, June 5, 2022. The format for all cells in that column is such that the first eight numbers always form a date "MMDDYYYY" and are followed by some string for example "_" three letters "_" some more numbers.
I was able to come up with this macro:
Sub Insert_Saba_Start_Date()
string_date = Split("06052022_GST_402", "_")(0)
string_year = Right(string_date, 4)
string_day = Mid(string_date, 3, 2)
string_month = Left(string_date, 2)
date_date = DateValue(string_month & "/" & string_day & "/" & string_year)
Range("F2").Value = date_date
End Sub
However, this macro does only the specific value mentioned in my example. How do I create a macro that will create insert the date when the date string in CLASS_NO column is different every time?
I need a macro that inserts dates into cells based on values from cells in another column.
Here's what my spreadsheet looks like:
CLASS_NO | STATUS | COURSE | DOMAIN | START_DATE |
06052022_GST_402 | 100 | 11202V | Shared | |
07042022_GMT_401 | 100 | 21201V | Shared | |
07062022_GMT_330 | 100 | 3267 | Shared |
I need to fill in the START_DATE column with start dates in format MM/DD/YYYY. The dates are based on the part of the string of numbers and letters from the CLASS_NO column that appear as a date. For example, in the first row you see "06052022_GST_402" and the first string of numbers are a date, June 5, 2022. The format for all cells in that column is such that the first eight numbers always form a date "MMDDYYYY" and are followed by some string for example "_" three letters "_" some more numbers.
I was able to come up with this macro:
Sub Insert_Saba_Start_Date()
string_date = Split("06052022_GST_402", "_")(0)
string_year = Right(string_date, 4)
string_day = Mid(string_date, 3, 2)
string_month = Left(string_date, 2)
date_date = DateValue(string_month & "/" & string_day & "/" & string_year)
Range("F2").Value = date_date
End Sub
However, this macro does only the specific value mentioned in my example. How do I create a macro that will create insert the date when the date string in CLASS_NO column is different every time?