I have an HTML report that can be opened in Excel. I have written macros to format this report so it is sortable and can have filters applied.
I am trying to grab text between slashes. The report size, how many rows, is unknown.
Column A is blank. Column B will contain the full path name. IF column B is populated, column C should have the text between the slashes.
For example, column B contains R:\testdocuments\test.html. I want column C to contain testdocuments.
Code I have for column C:
Range("C9").Select
ActiveCell.FormulaR1C1 = _
"=MID(RC[-1], FIND(""\"",RC[-1])+1, FIND(""\"",RC[-1], FIND(""\"",RC[-1])+1)-FIND(""\"",RC[-1])-1)"
Range("C9").Select
Selection.AutoFill Destination:=Range("C9:C65000"), Type:=xlFillDefault
Range("C9:C20000").Select
This is not effective because it takes forever to sort/filter anything.
How can I check if column B is populated and if it is, to populate C with the text between slashes for the ability to filter by directory?
First of all, a few general tips:
Use the following code at the beginning of your macro to prevent the application from animating (which slows it down):
Application.ScreenUpdating = FalseEdit: Make sure and set it back to ‘True’ after you’re done.
Range("C9:C65000"), you can actually let Excel find the last row for you usingRange("A1").SpecialCells(xlCellTypeLastCell).Row.So, the macro might look something like this: