VBA How to select a cell based on a target

Eean

New Member
Joined
May 26, 2010
Messages
44
Hi Hope you can help me - I'm tearing my hair out here.
I have this (Possibly uneloquent) code:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)


       Application.ScreenUpdating = False
       ActiveSheet.Unprotect


               
                
 If Target.Cells.Count > 1 Then Exit Sub


                      
          If Not Intersect(Target, Range("K3:K100")) Is Nothing Then
             With Target(1, 16)
            .Value = Date
            .EntireColumn.AutoFit


            
            End With
                End If


                
            If Not Intersect(Target, Range("K3:K100")) Is Nothing Then
            With Target(1, 17)
            .Value = Time
            .EntireColumn.AutoFit


            
            Columns("Z:AC").Select
            Selection.EntireColumn.Hidden = True


            
            
            ActiveSheet.protect
            
            Application.ScreenUpdating = True
            
            End With
                End If
                      
                        
                End Sub

When a value is entered in row 'K' I want the code to insert the date in row 'Z' and the Time in row 'AA' then Hide those two columns. That works fine, but when it's done it selects cell 'B3' for some reason. How would I write a line into that code that selects the next non blank cell in Column 'L'.

Hope this makes sense.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
I think I've worked it out.
(I still don't know what was causing it)
I added
Code:
Target.Offset(0,1).Select
Now it seems to be behaving.
Thanks
 
Upvote 0

Forum statistics

Threads
1,215,331
Messages
6,124,311
Members
449,152
Latest member
PressEscape

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