I'm writing a simple code to get some key figures from a database import/export. I want to make it user friendly, basically "one buttton click" gives the result.
When I wrote the code, I use Alt+F11 and "Play" => it works. But when I inserted the Active X-Control "CommandButton1_Click" the macro stops.
Here is where (first line):
ActiveSheet.ListObjects.Add(xlSrcRange, Range("A$1:$Be$1500"), , xlYes).Name = _
"Table1"
Range("Table1[#All]").Select
ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleLight1"
This is exactly the same code which works with the play button.
I get the error message:
"Run-time Error 1004:
The worksheet range for the table data must be on the same sheet as the table beeing created."
Does anyone have an idea?
An improvement to my code would be, to have the table length variable: There might be more rows in one set, and fewer in another data set.