Need Help Editing Code

Frith

Board Regular
Joined
Nov 1, 2009
Messages
99
Hi,

The below code snaps the cursor back to the last >0 cell in column B one second after ANY other cell in the WS is edited/entered... However, I'm trying to narrow this code to NOT apply to columns D & F (i.e., if I edit a cell in D or F, I do NOT want the cursor snapped back). Anyone know a way to tweak this?

Thanx a lot,
Frith


Dim LR As Long
LR = Range("B" & Rows.Count).End(xlUp).Row
If Target.Cells.Count > 1 Or IsEmpty(Target) Then
Exit Sub
Else
Application.Wait Time + TimeSerial(0, 0, 1)
Application.Goto Range("B" & LR)
End If
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi Frith,

Not sure what worksheet event you're using to run the code, but try this:

Code:
Dim LR As Long
    LR = Range("B" & Rows.Count).End(xlUp).Row
    If Target.Cells.Count > 1 Or _
       IsEmpty(Target) Or _
       Target.Column() = 4 Or _
       Target.Column() = 6 Then
        Exit Sub
    Else
        Application.Wait Time + TimeSerial(0, 0, 1)
        Application.Goto Range("B" & LR)
    End If

HTH

Robert
 
Upvote 0
untested, but i think it should work...

Code:
    Dim LR As Long

    if target.column() =4 or target.column()  = 6 then exit sub

    LR = Range("B" & Rows.Count).End(xlUp).Row
    If Target.Cells.Count > 1 Or IsEmpty(Target) Then
        Exit Sub
    Else
        Application.Wait Time + TimeSerial(0, 0, 1)
        Application.Goto Range("B" & LR)
    End If
 
Upvote 0
tRY
Code:
LR = Range("B" & Rows.Count).End(xlUp).Row
If target.Cells.Count > 1 Or IsEmpty(target) _
Or target.Column = 4 Or target.Column = 6 Then
Exit Sub
Else
Application.Wait Time + TimeSerial(0, 0, 1)
Application.Goto Range("B" & LR)
End If
 
Upvote 0

Forum statistics

Threads
1,224,567
Messages
6,179,568
Members
452,926
Latest member
rows and columns

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