We get daily summary emails into an inbox for all of our clients, but they come from the same email address so when we export them, the customers are all listed as the same email. The subject includes the customer name, so I need to copy ONLY the customer name from a cell in column 'M' in Excel, into a cell in column 'B'. This needs to happen for every single row in the worksheet, but I'm a little stuck on the code side. Please could I have some assistance?
For reference, the email subject we receive is: NEW ALERT (customer name > alert type > device)
So I'd want to be picking out the customer name, which would be between '(' and '>'. I'd then want to paste this in a cell in the same row, in column 'B'.
I'd want this to repeat for every cell in column 'M'.
I've tried various snippets of code, but none of them are the full deal, and my experience is so lackluster in VB I'm not entirely sure what I'm doing.
So my current code is as follows.
Sub CustomerNames()
Dim str As String
Dim openPos As Integer
Dim closePos As Integer
Dim midBit As String
str = ActiveSheet.Range("M" & Rows.Count).Select
openPos = InStr(str, "(")
closePos = InStr(str, ">")
midBit = Mid(str, openPos + 1, closePos - openPos - 1)
End Sub
So the results I'd like would be that the Macro would check every cell in column 'M', looking between the '(' and '>' character in the string to find the customer name. It should then copy the string it's found to the corresponding cell in the same row in column 'B'.
The actual output makes no change to the spreadsheet at the moment.