jski21
Board Regular
- Joined
- Jan 2, 2019
- Messages
- 153
- Office Version
- 2016
- Platform
- Windows
Good morning Mr. Excel Team,
I'm placing a macro inside a workbook and trying to create a table but receive a run time error 438; Object doesn't support this property or method. Here the code (bombs off on line 5):
'Convert all data to a Table, Add Table Style, Re-Fit Columns
Sheets("Clockify").Select
Sheets("Clockify").Range("A1").Select
Sheets("Clockify").Range(Selection, Selection.End(xlToRight)).Select
Sheets("Clockify").Range(Selection, Selection.End(xlDown)).Select
Sheets("Clockify").ActiveSheet.ListObjects.Add(xlSrcRange, Range([A1].End(xlDown), [A1].End(xlToRight)), , xlYes).Name = _
"Clockify"
Sheets("Clockify").Range("Table1[#All]").Select
Sheets("Clockify").ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleMedium3"
Sheets("Clockify").Range("A2").Select
I've used similar code in a macro that is housed in my PERSONAL workbook with no issue:
ActiveSheet.ListObjects.Add(xlSrcRange, Range([A1].End(xlDown), [A1].End(xlToRight)), , xlYes).Name = _
"Table1"
Range("Table1[#All]").Select
ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleMedium7"
Are there constraints or issues with doing the same when the macro is contained within the actual workbook? If so, why? In working through this I've found I've had to repeatedly select the sheet I'm running the macro on (command button is on another sheet) to get the code to progress.
Thanks in advance, as always, for the instruction and guidance.
jski
I'm placing a macro inside a workbook and trying to create a table but receive a run time error 438; Object doesn't support this property or method. Here the code (bombs off on line 5):
'Convert all data to a Table, Add Table Style, Re-Fit Columns
Sheets("Clockify").Select
Sheets("Clockify").Range("A1").Select
Sheets("Clockify").Range(Selection, Selection.End(xlToRight)).Select
Sheets("Clockify").Range(Selection, Selection.End(xlDown)).Select
Sheets("Clockify").ActiveSheet.ListObjects.Add(xlSrcRange, Range([A1].End(xlDown), [A1].End(xlToRight)), , xlYes).Name = _
"Clockify"
Sheets("Clockify").Range("Table1[#All]").Select
Sheets("Clockify").ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleMedium3"
Sheets("Clockify").Range("A2").Select
I've used similar code in a macro that is housed in my PERSONAL workbook with no issue:
ActiveSheet.ListObjects.Add(xlSrcRange, Range([A1].End(xlDown), [A1].End(xlToRight)), , xlYes).Name = _
"Table1"
Range("Table1[#All]").Select
ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleMedium7"
Are there constraints or issues with doing the same when the macro is contained within the actual workbook? If so, why? In working through this I've found I've had to repeatedly select the sheet I'm running the macro on (command button is on another sheet) to get the code to progress.
Thanks in advance, as always, for the instruction and guidance.
jski