Greetings all
I have been working on a macro this week that will insert a row underneath the header and write the formulas to the proper cells so that we can record production in a reasonably efficient manner. I do not claim to be a macro magician and I am sure there are better ways to accomplish some of the things I am doing, but it seem as though this particular macro has taken it upon itself to run too slow to be useful at all. The entire macro, comments and all is only 266 lines long (and there are a lot of comments as I wanted someone else to be able to go in a tell what was going on). It seemed to be working fine yesterday and I have been putting the final formulas in today before working on the formatting. When I tested it before lunch, it froze, so after lunch I ran it in debug mode and it isn't hanging on the back end where I have been working today, but at the very beginning. Can someone please take a look at this and see if there is something I am missing that would cause it to hang up?
Sub Production_Register_Line_Add()
'
Dim lrow As Long
Dim Gm_Lb As Double
Dim Gm_Oz As Double
Dim History As Integer
'*********************************************************************************************
Sheets("Variance Register").Select
'*********************************************************************************************
Range("7:7").Insert shift:=xlDown
Range("6:6").Copy Range("A7") 'This line is taking in excess of 30 seconds to execute
'On Error Resume Next
Rows("6").ClearContents
'*********************************************************************************************
' Declare Values for Constants
'*********************************************************************************************
lrow = Worksheets("Variance Register").Range("A" & Rows.Count).End(xlUp).Row
Gm_Lb = 453.5924
Gm_Oz = 28.349527
History = 180 'Number of days history to use when calculating Unit Cost Averages
'*********************************************************************************************
'
' A - Manufacturing Date (date when batch was actually made)
' B - Fill Date (Actual Production Date)
' C - Batch Number (Number stamped on jars to identify manufacture Batch)
' D - Finish Good Number
' E - Item Description
'
Range("E6").Formula = _
"=IFERROR(INDEX('\\Network\Company\Product Data\Product Data v1.00.xls'" _
& "!Item_Desc,MATCH($D6,'\\Network\Company\Product Data\[Product Data v1.00.xls]" _
& "Product Data'!Item_No,0)),"""")"
' This index(match()) is also taking in the neighborhood of 30 seconds to execute and I have 4 of these lookups
'more stuff
end sub
Right now, I have data going out to column BP and a little over 3,100 rows
I would appreciate it if anyone could see what I am doing that would cause this thing to hang up like it is.
Thanks
Bookmarks