pnwAnalyst
New Member
- Joined
- Oct 30, 2017
- Messages
- 9
I'm still really new to VBA. And this is the last portion of a long list of macros for completing data cleanup and analysis for a report. Maybe this isn't the best way to do this? I'm still new to this, so I'm open to other suggestions. But it needs to be a macro. This is basically what it looks like (the * fields are filled with a vlookup, which is why I have two different arrays because they're not contiguous):
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]mfg #[/TD]
[TD]mfg # alt[/TD]
[TD]desc[/TD]
[TD]brand[/TD]
[TD]uom[/TD]
[TD]qtyuom[/TD]
[TD]mfgname[/TD]
[TD]mfgcode[/TD]
[TD]mfgtype[/TD]
[TD]contract[/TD]
[TD]contractnum[/TD]
[TD]supcode[/TD]
[TD]effdate[/TD]
[TD]expdate[/TD]
[TD]$date[/TD]
[TD]$exp[/TD]
[TD]status[/TD]
[/TR]
[TR]
[TD]*[/TD]
[TD]*[/TD]
[TD]*[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]*[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[/TR]
[TR]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[/TR]
</tbody>[/TABLE]
The number of rows varies depending on the report. Sometimes its 4000 rows, sometimes its more, sometimes its less. But I've made sure that every column would be the same. We're trying to automate as much of it as we can so that we might be able to get some less-technical people to be able to run through the entire process. The first time I went through the process it took me 6 hours (although I was taking notes too). For the senior person here it takes about 2 hours for each one, depending. We have somewhere around 300 of these to do before the end of the year.
Anyways, this code works, but only for the first row. Which makes sense because that's what I've told it to do in setting the ranges. But when I tried to get it to fill down it filled every single row in the entire worksheet and crashed excel. Any help would be appreciated.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]mfg #[/TD]
[TD]mfg # alt[/TD]
[TD]desc[/TD]
[TD]brand[/TD]
[TD]uom[/TD]
[TD]qtyuom[/TD]
[TD]mfgname[/TD]
[TD]mfgcode[/TD]
[TD]mfgtype[/TD]
[TD]contract[/TD]
[TD]contractnum[/TD]
[TD]supcode[/TD]
[TD]effdate[/TD]
[TD]expdate[/TD]
[TD]$date[/TD]
[TD]$exp[/TD]
[TD]status[/TD]
[/TR]
[TR]
[TD]*[/TD]
[TD]*[/TD]
[TD]*[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]*[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[/TR]
[TR]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[TD]aaa[/TD]
[/TR]
</tbody>[/TABLE]
The number of rows varies depending on the report. Sometimes its 4000 rows, sometimes its more, sometimes its less. But I've made sure that every column would be the same. We're trying to automate as much of it as we can so that we might be able to get some less-technical people to be able to run through the entire process. The first time I went through the process it took me 6 hours (although I was taking notes too). For the senior person here it takes about 2 hours for each one, depending. We have somewhere around 300 of these to do before the end of the year.
Anyways, this code works, but only for the first row. Which makes sense because that's what I've told it to do in setting the ranges. But when I tried to get it to fill down it filled every single row in the entire worksheet and crashed excel. Any help would be appreciated.
Code:
Sub AutomateAllTheThings6()
Dim arr3() As String
Dim arr11() As String
Dim rng3 As Range
Dim rng11 As Range
Dim sourcerng As Range
Set rng3 = ActiveSheet.Range("BH2:BJ2")
Set rng11 = ActiveSheet.Range("BL2:BV2")
Set sourcerng = ActiveSheet.Range("BE2:BF2")
'Set sourcerng = ActiveSheet.Range("BE:BF" & Range("BD" & Rows.count).End(xlUp).Row)
arr3() = Split("UNKNOWN,UNKNOWN,UNKNOWN", ",")
arr11() = Split("UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, 00/00/0000, 00/00/0000, 00/00/0000, 00/00/0000, NEEDS REVIEW", ",")
Call OptimizeCode_Begin
For Each cell In sourcerng
If IsEmpty(cell) Then
rng3.Value = arr3
rng11.Value = arr11
End If
Next
Call OptimizeCode_End
End Sub
Last edited: