Engalpengal
New Member
- Joined
- May 10, 2023
- Messages
- 43
- Office Version
- 365
- Platform
- Windows
Hello.
I am working on a project, where i want to track products in our factory.
The process start by me loading orders in a workbook called "Ordre"
It is a list of products with information spread out in rows C:P - See Pic 1
When a process is done, a date is filled in Q:AF depending on witch prosess that is completed (VBA program). These columns is hidden. - See Pic 2
In column AH:AV I have excel formulas that shows If the product should go throug the process (No=x, Yes=Process desc ex. PR), or if the process is done(Done=V). - See Pic 3
Ex of formulas: =IF(C22<1;"";IF(AE22>1;"V";XLOOKUP(F22;BOM!A:A;BOM!AC:AC;"x";0)))
With a click of a button all Product lines With "V" in column AV (the last process) is copied into av workbook called History.
Now i need to cleare (ClearContents) the same lines that was copied into History, from workbook "Ordre".
Under follows my attempt.
The program does not give me an Error, but nothing happens either, other than the workbook is thinking.
So what am i doing wrong?
I am working on a project, where i want to track products in our factory.
The process start by me loading orders in a workbook called "Ordre"
It is a list of products with information spread out in rows C:P - See Pic 1
When a process is done, a date is filled in Q:AF depending on witch prosess that is completed (VBA program). These columns is hidden. - See Pic 2
In column AH:AV I have excel formulas that shows If the product should go throug the process (No=x, Yes=Process desc ex. PR), or if the process is done(Done=V). - See Pic 3
Ex of formulas: =IF(C22<1;"";IF(AE22>1;"V";XLOOKUP(F22;BOM!A:A;BOM!AC:AC;"x";0)))
With a click of a button all Product lines With "V" in column AV (the last process) is copied into av workbook called History.
Now i need to cleare (ClearContents) the same lines that was copied into History, from workbook "Ordre".
Under follows my attempt.
The program does not give me an Error, but nothing happens either, other than the workbook is thinking.
So what am i doing wrong?
VBA Code:
Sub Fjern_ferdig()
unprotect
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Dim wbo As Workbook
Dim wsSrc As Worksheet
Dim i As Integer
Set wbo = ThisWorkbook
Set wsSrc = wbo.Worksheets("Ordre") '______________________________________________________Sheet for search area
Set srcKey = wsSrc.Range("AV8") '___________________________________________________________Search key (The cell contains the letter V)
finalrow = wsSrc.Range("AV1000").End(xlUp).Row '__________________________________________Setting search area (These cells contains excel formulas)
For i = 48 To finalrow
If Cells(i, 48) = srcKey Then
wsSrc.Range(Cells(i, 3), Cells(i, 32)).ClearContents
End If
Next i
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
protect
ActiveWorkbook.Save
End Sub
Sub unprotect()
ActiveSheet.unprotect "1234"
End Sub
Sub protect()
ActiveSheet.protect "1234"
End Sub