Lagging problem.

Agnarr

New Member
Joined
Jan 15, 2023
Messages
29
Office Version
  1. 365
Platform
  1. Windows
Hello everybody and you all do an amazing work.
I need your help please and i apologize in advance for any mistakes (English is not my native language).

I wanted to make a log where you type a code and have it replaced by the name of a client. The brilliant bebo021999 gave me a quick and easy solution but there's one problem.
I have a button that completely empties out the log but now it lags incredibly. Like it tries to read each row and then clears contents and while it does so, resets the height as well.
Is there a workaround to this lagging problem?

The code for the replacement by bebo021999 is this:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim inputR As Range, codeR As Range, cell As Range
Dim f
Set inputR = Range("C14:C208") ' range of input data. adjust to actual range
Set codeR = Worksheets("ÊÙÄ.ÐÅË.").Range("A1:B300") ' assums sheet "code", range "A1:B3" contains lookup code. Adjust to actual sheet-range
If Intersect(Target, inputR) Is Nothing Then Exit Sub
With Application
    .EnableEvents = False
    For Each cell In Target
        Set f = codeR.Find(cell.Value, , , xlWhole)
        If Not f Is Nothing Then cell.Value = f.Offset(, 1).Value
    Next
    .EnableEvents = True
End With
End Sub

and the module to empty out the log is this:
VBA Code:
Sub ClearLogContents()
Range("B14:L208").ClearContents
Range("C10:F11").ClearContents
Range("H10:L11").ClearContents
End Sub

Sorry but I don't know how to upload the workbook here yet.
Thank you all in advance. Any help will be appreciated.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Try:
VBA Code:
Sub ClearLogContents()
    Application.EnableEvents = False
    Range("B14:L208").ClearContents
    Range("C10:F11").ClearContents
    Range("H10:L11").ClearContents
    Application.EnableEvents = True
End Sub
Is this post related to your more recent post that I responded to?
 
Upvote 0
Solution
Try:
VBA Code:
Sub ClearLogContents()
    Application.EnableEvents = False
    Range("B14:L208").ClearContents
    Range("C10:F11").ClearContents
    Range("H10:L11").ClearContents
    Application.EnableEvents = True
End Sub
Is this post related to your more recent post that I responded to?
No. That's from another workbook entirely!
 
Upvote 0

Forum statistics

Threads
1,223,975
Messages
6,175,742
Members
452,667
Latest member
vanessavalentino83

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top