inked
08-05-2006, 01:29 PM
I'm extremely new to VBA. I've had some help with the following macro:
Option Explicit
Dim Cell As Range
Dim CopyNames As Range
Sub ShuffleNames()
Dim FirstName As String
Dim LastName As String
Dim CommaLoc As Long
For Each Cell In CopyNames
If Not IsEmpty(Cell.Value) Then
CommaLoc = InStr(Cell.Value, ",")
LastName = Left(Cell.Value, CommaLoc - 1)
FirstName = Right(Cell.Value, Len(Cell.Value) - CommaLoc)
LastName = Application.Proper(LastName)
FirstName = Application.Proper(FirstName)
Cell.Value = FirstName & " " & LastName
End If
Next Cell
End Sub
I've placed it in a module and defined the range within the workbook. I keep getting and error saying object required and highlighting "For Each Cell In CopyNames"
I'm using Office 2004 for the Mac.
Thanks.
-ep
Option Explicit
Dim Cell As Range
Dim CopyNames As Range
Sub ShuffleNames()
Dim FirstName As String
Dim LastName As String
Dim CommaLoc As Long
For Each Cell In CopyNames
If Not IsEmpty(Cell.Value) Then
CommaLoc = InStr(Cell.Value, ",")
LastName = Left(Cell.Value, CommaLoc - 1)
FirstName = Right(Cell.Value, Len(Cell.Value) - CommaLoc)
LastName = Application.Proper(LastName)
FirstName = Application.Proper(FirstName)
Cell.Value = FirstName & " " & LastName
End If
Next Cell
End Sub
I've placed it in a module and defined the range within the workbook. I keep getting and error saying object required and highlighting "For Each Cell In CopyNames"
I'm using Office 2004 for the Mac.
Thanks.
-ep