Two problems. 1) I can't reference the cells like I'd prefer. 2) I can't get the worksheet renamed.
I import a text file with the file create date preceded with a space as the last value. So the last entry in column A is the date the text file. I'm trying to concatenate the text "User Accounts" and the value in the last row of column A. I "thought" I could use the same expression that creates the last row reference, but that generates an error.
And I can't get the worksheet renamed.
TIA to anyone with the time to look this over and educate me.
Ron
I import a text file with the file create date preceded with a space as the last value. So the last entry in column A is the date the text file. I'm trying to concatenate the text "User Accounts" and the value in the last row of column A. I "thought" I could use the same expression that creates the last row reference, but that generates an error.
And I can't get the worksheet renamed.
TIA to anyone with the time to look this over and educate me.
Ron
VBA Code:
Sub m_DateUserText()
Application.DisplayAlerts = False
Application.DisplayStatusBar = False
Application.ScreenUpdating = False
'
ws_2Users.Activate
'
Dim LastRow As Long
Dim LastCol As Integer
Dim OneName As Name
Dim ThisWsName As Range
Dim ThisWsDate As Range
Dim ThisWs As Worksheet
Dim ThisWb As Workbook
'
Set ThisWb = ActiveWorkBook
Set ThisWs = ActiveSheet
'
For Each OneName In ThisWb.Names
On Error Resume Next
If OneName.RefersToRange.Parent.Name = "ws_2Users" Then OneName.Delete
On Error GoTo 0
Next OneName
'
With ThisWs
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
Cells(LastRow, 1).Name = "ThisWsDate"
Cells(LastRow, 1).Offset(1).Name = "ThisWsName"
With ThisWs
ThisWsName.FormulaR1C1 = "= ""User Accounts "" & Range(ThisWsDate).Value "
.Name = ThisWsName
End With
'Range(ThisWsDate).EntireRow.Delete 'not used, retained for reference
'Range(ThisWsName).EntireRow.Delete 'not used, retained for reference
'Set ThisWsDate = Nothing 'not used, retained for reference
'Set ThisWsName = Nothing 'not used, retained for reference
Cells(1, 1).Select
End With 'ThisWs
'
End Sub