Slow Procedure

G

Guest

Guest
Hi all,
I have this code to grab the first 3 chars from a line. Problem is.. whenever its running, the cursor quickly switches from the normal arrow to hourglass, giving it a flickering effect. Any ways to eliminate that?? Also, I have already set screenUpdating = False.


Sub GetSVCodeFromLine16()

Dim objLastCell As Object, cell As Object, strSVCode As String

Set objLastCell = RealLastCell(Application.ActiveSheet)

For Each cell In Range("S2", objLastCell)
strSVCode = Left(Trim(cell.Value), 3)
cell.Offset(rowOffset:=0, columnOffset:=1).FormulaR1C1 = UCase(strSVCode)
Next cell

End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
No too sure if your last cell is in Column "S", but if so use:

Sub GetSVCodeFromLine16()

Dim objLastCell As Range, cell As Range

Range("S2", Range("S65536").End(xlUp)) _
.FormulaR1C1 = "=UPPER(LEFT(TRIM(RC[-1]),3))"

Range("S2", Range("S65536").End(xlUp)) = _
Range("S2", Range("S65536").End(xlUp)).Value

End Sub

Loops ae generally very slow in comparison.

Not to sure what method you are using to find the real last cell either but the safets way is via the Find Method. I have many examples here: http://www.ozgrid.com/VBA/ExcelRanges.htm
 
Upvote 0

Forum statistics

Threads
1,213,506
Messages
6,114,025
Members
448,543
Latest member
MartinLarkin

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