Hi there
I have a CASE statement that is looping through a very large data set (>75,000 rows) and if the state says "New South Wales" i need it changed to NSW. I need this abbreviation for all Australian states. My code works but it is taking FOREVER to loop through all the data.
Can i convert my data ranges into an array to speed things up? I'm not sure what to do. Basically if the state says New South Wales I want that same cell changed to NSW. Here's my code:
any help is very much appreciated.
Many thanks
---
dim lRowCount as long
Dim i As Long
Application.ScreenUpdating = False
lRowCount = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lRowCount
strState = Application.Worksheets("ClientAddress").Cells(i, 8) 'being where i'm storing my state value
Select Case strState
Case "New South Wales"
Application.ActiveSheet.Cells(i, 8) = "NSW"
'strState = "NSW"
Case "Queensland"
Application.ActiveSheet.Cells(i, 8) = "QLD"
Case "Victoria"
Application.ActiveSheet.Cells(i, 8) = "VIC"
Case "Tasmania"
Application.ActiveSheet.Cells(i, 8) = "TAS"
Case "Western Australia"
Application.ActiveSheet.Cells(i, 8) = "WA"
Case "Australian Capital Territory"
Application.ActiveSheet.Cells(i, 8) = "ACT"
Case "Northern Territory"
Application.ActiveSheet.Cells(i, 8) = "NT"
Case "South Australia"
Application.ActiveSheet.Cells(i, 8) = "SA"
End Select
Next i
I have a CASE statement that is looping through a very large data set (>75,000 rows) and if the state says "New South Wales" i need it changed to NSW. I need this abbreviation for all Australian states. My code works but it is taking FOREVER to loop through all the data.
Can i convert my data ranges into an array to speed things up? I'm not sure what to do. Basically if the state says New South Wales I want that same cell changed to NSW. Here's my code:
any help is very much appreciated.
Many thanks
---
dim lRowCount as long
Dim i As Long
Application.ScreenUpdating = False
lRowCount = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lRowCount
strState = Application.Worksheets("ClientAddress").Cells(i, 8) 'being where i'm storing my state value
Select Case strState
Case "New South Wales"
Application.ActiveSheet.Cells(i, 8) = "NSW"
'strState = "NSW"
Case "Queensland"
Application.ActiveSheet.Cells(i, 8) = "QLD"
Case "Victoria"
Application.ActiveSheet.Cells(i, 8) = "VIC"
Case "Tasmania"
Application.ActiveSheet.Cells(i, 8) = "TAS"
Case "Western Australia"
Application.ActiveSheet.Cells(i, 8) = "WA"
Case "Australian Capital Territory"
Application.ActiveSheet.Cells(i, 8) = "ACT"
Case "Northern Territory"
Application.ActiveSheet.Cells(i, 8) = "NT"
Case "South Australia"
Application.ActiveSheet.Cells(i, 8) = "SA"
End Select
Next i