Hi gmaxey,
Like always xld with awesome ideas and suggestions. You can use the macro recorder to get a lot of information.
So here is the code implementing xld suggestion. There are other wasy to sort of get the same result. Like conditional formatting rules. I was actually trying that one out but I got an error in line ExecuteExel4Macro, so I gave up. I made some other changes to your code to shrink it a little ( and to apply what I am learning in the forum)
Some links here
http://www.mrexcel.com/forum/showthr...mula-Questions
http://www.ozgrid.com/Excel/highlight-duplicates.htm
Here is the modified code:
[vba]Function CreateDataSheet() As String
Dim strFname As String
Dim strPath As String
Const strCaption As String = "Save the Excel data file in a folder of your choice. " & _
"You may change the default name if you wish."
'ShowError 2, 8
'Unload frmNotification
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
If Err Then
Set xlApp = CreateObject("Excel.Application")
End If
On Error GoTo 0
Set xlWB = xlApp.Workbooks.Add
Set xlSheet = xlWB.Sheets(1)
'rename the sheet to something meaningful
Application.Sheets(1).Name = "Data"
With xlSheet.Cells(1, 1).Resize(1, 6)
.Value = Array("Client ID", "Company Name", "Name", "Address", "e-mail", "Terms")
'I like my headers bold and centered but its up to you
.Font.Bold = True
.HorizontalAlignment = xlCenter
End With
With xlSheet
.Cells(1, 1).ColumnWidth = 10
.Cells(1, 2).Resize(, 3).ColumnWidth = 30
.Cells(1, 4).ColumnWidth = 75
.Cells(1, 5).Resize(, 6).ColumnWidth = 20
End With
'use this to set the data validation up to row 100000000
With Range("A2:A1000000").Validation
.Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=COUNTIF($A$2:$A2,$A2)=1"
.IgnoreBlank = True
.InCellDropdown = True
.ErrorTitle = "ID Check"
.ErrorMessage = "This ID is already in use please use a different one"
.ShowError = True
End With
strFname = xlApp.GetSaveAsFilename("CustomClientList.xlsx", _
"Excel files (*.xlsx),*.xlsx", 1, strCaption)
If strFname <> "False" Then
xlWB.SaveAs strFname
End If
strPath = xlWB.FullName
xlWB.Close SaveChanges:=False
Set xlApp = Nothing
Set xlWB = Nothing
Set xlSheet = Nothing
CreateDataSheet = strPath
End Function
[/vba]
Thanks