现在我使用下面的代码将整列更改为小写。
我想知道是否有更有效的方法来做到这一点 - 我的工作表中有大约 150K 行。
完成需要一些时间,有时我会收到Out of Memory
错误消息。
第一个子
Sub DeletingFl()
Dim ws1 As Worksheet
Dim rng1 As Range
Application.ScreenUpdating = False
Set ws1 = Sheets("Raw Sheet")
ws1.AutoFilterMode = False
Set rng1 = ws1.Range(ws1.[a1], ws1.Cells(Rows.Count, "A").End(xlUp))
rng1.AutoFilter 1, "Florida"
If rng1.SpecialCells(xlCellTypeVisible).Count > 1 Then
Set rng1 = rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1)
rng1.EntireRow.Delete
End If
ws1.AutoFilterMode = False
Call DeletingEC
End Sub
Sub DeletingEC()
Dim ws1 As Worksheet
Dim rng1 As Range
Application.ScreenUpdating = False
Set ws1 = Sheets("Raw Sheet")
ws1.AutoFilterMode = False
Set rng1 = ws1.Range(ws1.[a1], ws1.Cells(Rows.Count, "A").End(xlUp))
rng1.AutoFilter 1, "East Coast"
If rng1.SpecialCells(xlCellTypeVisible).Count > 1 Then
Set rng1 = rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1)
rng1.EntireRow.Delete
End If
ws1.AutoFilterMode = False
Worksheets("Raw Sheet").Activate
Call Concatenating
End Sub
第二个子
Sub Concatenating()
Columns(1).EntireColumn.Insert
Columns(2).EntireColumn.Copy Destination:=ActiveSheet.Cells(1, 1)
Dim lngLastRow As Long
lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:A" & lngLastRow).Formula = "=F2 & ""_"" & G2"
Range("A1").Select
ActiveCell.FormulaR1C1 = "Title"
Call LowerCasing
End Sub
Sub Lowercasing()
Dim myArr, LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
myArr = Range("A1:A" & LR)
For i = 1 To UBound(myArr)
myArr(i, 1) = LCase(myArr(i, 1))
Next i
Range("A1:A" & LR).Value = myArr
Set ExcelSheet = Nothing
End Sub