Hello,
I have a workbook that has many rows of data. I wrote a macro that filters on column B, then the macro inserts a formula into column C to copy over the first 4 characters. I am using this line of code to bring the characters over filling in to the last row.
<code>
'Below Inserts a formula that brings over just the first 4 letters of column B.
On Error Resume Next
ActiveSheet.Range("C2:C" & ActiveSheet.Cells(rows.Count, 2).End(xlUp).row).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "=LEFT(RC[-1],4)"
On Error GoTo 0
Worksheets("Sheet1").Columns(10).Calculate
</code>
The problem is if there is only one row with the filter parameter I get a warning about not enough memory or something. I tested this by adding another fake row that matches my filter parameter just so I could have 2 rows, and it works fine.
Is there a way to modify this code so if there is only 1 row of data it won't give me a warning?
I have a workbook that has many rows of data. I wrote a macro that filters on column B, then the macro inserts a formula into column C to copy over the first 4 characters. I am using this line of code to bring the characters over filling in to the last row.
<code>
'Below Inserts a formula that brings over just the first 4 letters of column B.
On Error Resume Next
ActiveSheet.Range("C2:C" & ActiveSheet.Cells(rows.Count, 2).End(xlUp).row).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "=LEFT(RC[-1],4)"
On Error GoTo 0
Worksheets("Sheet1").Columns(10).Calculate
</code>
The problem is if there is only one row with the filter parameter I get a warning about not enough memory or something. I tested this by adding another fake row that matches my filter parameter just so I could have 2 rows, and it works fine.
Is there a way to modify this code so if there is only 1 row of data it won't give me a warning?