Reputation: 124
So in cell let's say "b1" I have a Data validation with the following (whatever is written after the date and a space is the Project name):
05/01/2016 I like icecreams
05/01/2016 Project B: whatever
12/01/2016 Project Me!
18/01/2016 Hello world
01/02/2016 I like chocolate
27/02/2016 Real business
I created a macro that checks the "b1" name and if it is equal it does something. My problem is that I recently added the Date to the data validation because I needed to ease the burden of knowing when the Project started.
In my macros I have for example this variable:
projectname = Sheet1.Range("b1").Value
This variable no longer gets positive results because the Date is also in the Data validation. I need something like only consider the right part after 11 characters of what is written in "b1".
How can I change the way the variable is set up in Excel-VBA?
Upvotes: 0
Views: 39
Reputation: 19289
If the date is always going to be the 11 characters of dd/mm/yyyy plus the space then the variable assignment would be:
Dim strCellValue As String
Dim strProjectName As String
strCellValue = Sheet1.Range("b1").Value
strProjectName = Right$(strCellValue, Len(strCellValue) - 11)
Upvotes: 2