VBA - Extract Second word from Cell and Extract word before ","

eli_m

Board Regular
Joined
Jun 2, 2022
Messages
154
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am currently using:
Cells(ActiveCell.Row, "F").Value
Which is "John Doe" but I only want it to display the second word "Doe"

I also have

Cells(ActiveCell.Row, "A").Value
Which is "SMITH RODGERS, Jane" but I only want it to display the words that appear before the "," so it displays "SMITH RODGERS"

The full code is:
VBA Code:
Option Explicit
Sub CalendarInvite()
    Dim OutApp As Outlook.Application, Outmeet As Outlook.AppointmentItem

        Set OutApp = Outlook.Application
        Set Outmeet = OutApp.CreateItem(olAppointmentItem)
        
        With Outmeet
            .MeetingStatus = olMeeting
            .ReminderMinutesBeforeStart = 15
            .Subject = "Support: " & Cells(ActiveCell.Row, "F").Value & " Client: " & Cells(ActiveCell.Row, "A").Value & " - BOOKED"
            .Body = Cells(ActiveCell.Row, "J").Value
            .Location = Cells(ActiveCell.Row, "H").Value
            .Start = Cells(ActiveCell.Row, "B").Value
            .AllDayEvent = True
            .Display
        End With

    Set OutApp = Nothing
    Set Outmeet = Nothing
End Sub

Thanks in advance :)
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
From your description & then looking at your code I imagine that it is just the "Subject" line that you are talking about. If so, try this for that line

VBA Code:
.Subject = "Support: " & Split(Cells(ActiveCell.Row, "F").Value)(1) & " Client: " & Split(Cells(ActiveCell.Row, "A").Value, ",")(0) & " - BOOKED"
 
Upvote 0
Solution
From your description & then looking at your code I imagine that it is just the "Subject" line that you are talking about. If so, try this for that line

VBA Code:
.Subject = "Support: " & Split(Cells(ActiveCell.Row, "F").Value)(1) & " Client: " & Split(Cells(ActiveCell.Row, "A").Value, ",")(0) & " - BOOKED"
As soon as I got the email that "Peter_SSs replied" I knew it was going to be the right answer!
Thank you so much :)
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,195
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top