A VBA beginner here. I'm trying to write a code that will add a new column, and using a loop to fill the values in the new column, based on information from other columns. E.g., if a cell in Column 'AL' has "Germany" on it, it will also write "Germany on the new column. The problem is, that the worksheet includes more than 50k rows and 50 columns, and it takes a few minutes for the loop to be completed. So what I did, is to first filter some values on column 'AL' ("Germany" and "UK"..), run a loop, and then run the loop on another filtered column. But it still takes ages for the two loop to finish.
I wonder if there's a way to improve the process? I think that even though I filtered it, the loop still runs on all values, not just the visible ones.
Sub Macro6()
'Filter Germany,UK, EMEA
Range("AL2").EntireColumn.Insert
Range("A1").CurrentRegion.AutoFilter 42, Array("Germany", "UK","EMEA") ''''''
Range("AQ3").Select
'Create a loop to insert values
Do Until ActiveCell.Value = ""
If ActiveCell.Value = "Germany" Then
ActiveCell.Offset(0, -5).Value = "Germany"
ElseIf ActiveCell.Value = "UK" Then
ActiveCell.Offset(0, -5).Value = "UKI"
ActiveCell.Offset(0, -5).Value = "EMEA"
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub
Sub Macro7()
'Filter APAC, Americas and EMEA
If ActiveSheet.FilterMode = True Then ActiveSheet.ShowAllData
Range("A1").CurrentRegion.AutoFilter 38, Array("Americas", "Asia/Pacific", "EMEA")
Range("AM3").Select
'Create a loop to insert values
Do Until ActiveCell.Value = ""
If ActiveCell.Value = "Americas" Then
ActiveCell.Offset(0, -1).Value = "Americas"
ElseIf ActiveCell.Value = "EMEA" Then
ActiveCell.Offset(0, -1).Value = "EMEA"
ElseIf ActiveCell.Value = "Asia/Pacific" Then
ActiveCell.Offset(0, -1).Value = "APAC"
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub