Hello,
I am learning VBA and have a large code that formats an Excel spreadsheet. The code works, but I just want to see if there is a better way to write the code of Autofit and Autofilter than what I have below for the sake of learning. I ask, too, b/c I hear some people say to not use Select in code, and I didn't know if I was doing that in the codes below.
I tried to use other code to just apply autofilter by recognizing the top row of the used range, but it caused problems and another code would add filter to the entire row in Excel.
This is what code came up when I created a macro to autofit. I removed the Cell.Select part that was at the beginning b/c, as I mentioned, I've heard you shouldn't use Select. Will this cause any problems by being too generic or anything?
Thank you.
I am learning VBA and have a large code that formats an Excel spreadsheet. The code works, but I just want to see if there is a better way to write the code of Autofit and Autofilter than what I have below for the sake of learning. I ask, too, b/c I hear some people say to not use Select in code, and I didn't know if I was doing that in the codes below.
Code:
'turn on autofilter
Range("A1").AutoFilter
I tried to use other code to just apply autofilter by recognizing the top row of the used range, but it caused problems and another code would add filter to the entire row in Excel.
Code:
'autofit columns
Cells.EntireColumn.AutoFit
This is what code came up when I created a macro to autofit. I removed the Cell.Select part that was at the beginning b/c, as I mentioned, I've heard you shouldn't use Select. Will this cause any problems by being too generic or anything?
Thank you.