I'm having trouble writing this single line of code correctly so that it works and it doesnt give me an error: (errror = "Method of Range of Object_Worksheet failed")
(this does NOT work: )
I have another similar line of code in a different module that does work. I am trying to modify that one to work for this module. The one that works only finds the first blank row in the range, and the new one (the one I am tyring to get to work) I need it to find both the first empty row AND the first empty column.
Here is the code that DOES work that I am currently trying to change up...
(this does work: )
And here is the error that I keep getting: (along with showing some of the iterations of writing the line of code... none of which worked correctly.)
And in case it helps or provides any additional info for what I am trying to do, here is the entire code for this section:
Thanks for any help that is offered!!
(this does NOT work: )
VBA Code:
Set TempRange = qq.Range("A1:" & "LastRow & LastColumn")
I have another similar line of code in a different module that does work. I am trying to modify that one to work for this module. The one that works only finds the first blank row in the range, and the new one (the one I am tyring to get to work) I need it to find both the first empty row AND the first empty column.
Here is the code that DOES work that I am currently trying to change up...
(this does work: )
VBA Code:
Set TempRange = ztt.Range("A18:AW" & LastRow)
And here is the error that I keep getting: (along with showing some of the iterations of writing the line of code... none of which worked correctly.)
And in case it helps or provides any additional info for what I am trying to do, here is the entire code for this section:
VBA Code:
'
' UPDATE THE NAMED RANGE ""Dynamic Tracker Range" WHEN A NEW ROW/COLUMN IS ADDED TO THE "TRAINING TRACKER" WORKSHEET:
Dim qq As Worksheet
Set qq = Worksheets("Training Tracker")
Dim TempRange As Range
Dim LastRow As Long
'LastRow = qq.Cells.Find("*", , , , xlByRows, xlPrevious, , , False).Row
LastRow = qq.UsedRange.Rows.Count
Dim LastColumn As Long
LastColumn = qq.Cells.Find("*", , , , xlByColumns, xlPrevious, , , False).Column
Dim myRangeName As String
' *none of these iterations work:*
'Set TempRange = qq.Range("A1:" & LastRow, LastColumn)
'Set TempRange = qq.Range("A1:" & LastRow & LastColumn)
'Set TempRange = qq.Range("A1:" & "LastRow:LastColumn")
'Set TempRange = qq.Range("A1:" & "LastRow, LastColumn")
Set TempRange = qq.Range("A1:" & "LastRow & LastColumn")
myRangeName = "DynamicTrackerRange2"
'Creates the new named range with workbook scope. Defined name and cell range are as specified
ThisWorkbook.Names.Add Name:=myRangeName, RefersTo:=TempRange
'
Thanks for any help that is offered!!