Johnny Thunder
Well-known Member
- Joined
- Apr 9, 2010
- Messages
- 693
- Office Version
- 2016
- Platform
- MacOS
Hello everyone,
I am working on a project that will at some point get migrated into an actual database but at the moment is being managed in excel and the data has gotten really large. The Row count of the report has now hit over 300k+ across 12 columns. Unfortunately there is no way to trim off old data so I am stuck with this report as is.
Need:
I have a macro that loops thru one column and looks for a specific "Type" and if found revises one column value with another value and if it finds anything other than a specific "Type" if will also process a revision. Currently, the only way that seems to work for me with my limited knowledge of large loops is a For Each statement but I am hoping someone can think of a better/faster way to do this that went get an 'Overflow' error due to the high data set.
Code currently takes 8min to run so hoping to get that time down to under a minute if possible. Any help is appreciated.
*I am also doing this on a mac version of excel which does not have the ActiveX module active or allow for creating libraries but most all other codes work without issues.
Here is the current code:
I am working on a project that will at some point get migrated into an actual database but at the moment is being managed in excel and the data has gotten really large. The Row count of the report has now hit over 300k+ across 12 columns. Unfortunately there is no way to trim off old data so I am stuck with this report as is.
Need:
I have a macro that loops thru one column and looks for a specific "Type" and if found revises one column value with another value and if it finds anything other than a specific "Type" if will also process a revision. Currently, the only way that seems to work for me with my limited knowledge of large loops is a For Each statement but I am hoping someone can think of a better/faster way to do this that went get an 'Overflow' error due to the high data set.
Code currently takes 8min to run so hoping to get that time down to under a minute if possible. Any help is appreciated.
*I am also doing this on a mac version of excel which does not have the ActiveX module active or allow for creating libraries but most all other codes work without issues.
Here is the current code:
VBA Code:
Sub AlterDownload()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim LastR1 As String, LastR2 As Long
Dim Count As String
Dim ceLL As Range
Dim r As Long
Set ws1 = Sheets("Download")
Set ws2 = Sheets("Lookup")
LastR1 = ws1.Range("F" & Rows.Count).End(xlUp).Row
LastR2 = ws2.Range("B" & Rows.Count).End(xlUp).Row
For Each ceLL In ws1.Range("G2:G" & LastR1)
r = ceLL.Row
If ceLL.Value = "EpisodeVersion" Then
ws1.Range("P" & r).Value = ws1.Range("C" & r).Value
Else
ws1.Range("P" & r).Value = ws1.Range("A" & r).Value
End If
Next ceLL
End sub
Last edited: