need offset macro

eddieg

New Member
Joined
Jun 28, 2024
Messages
4
Office Version
  1. 2010
Platform
  1. Windows
using this: Private Sub Worksheet_Change(ByVal Target As Range)
I need a macro that moves any activecell in the column J to move 4 cells to the left when i hit enter...... offset(0,-4)

thank you very much
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi
I'm not sure if you mean this(I prefer use select cell)
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Not Intersect(Range("J1:J10"), Target) Is Nothing Then ' expend range  if you need
    Target.Offset(, -4) = Target.Value
    End If
End Sub
 
Upvote 0
Hi
I'm not sure if you mean this(I prefer use select cell)
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Not Intersect(Range("J1:J10"), Target) Is Nothing Then ' expend range  if you need
    Target.Offset(, -4) = Target.Value
    End If
End Sub
This doesn't seem to work, thank you however.....let me clarify, I put text in each cell in the J column and when I hit enter, i want it to offset the the left 4 cells in the same row.
 
Upvote 0
I'm not sure why you insist use ENTER key!
what's the aim?!
This doesn't seem to work
you should be more specifically what happens for you.
the code depends on select cell then will copy the left 4 cells.
in sheet module doesn't contain Enter event to do that , I'm not sure if it's possible do that by create function , this is out of my capability, sorry!
you should wait for else body to help you.
good luck.
 
Upvote 0
this?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.CountLarge > 1 Then Exit Sub
    If Not Intersect(Range("J1:J10"), Target) Is Nothing Then
    Target.Offset(, -4).Value = Target.Value
    End If
End Sub
 
Upvote 0
Sorry, let me rephrase this.....as i enter text data in each cell in column J, then either tab or hit enter, i want it to activate the cell 4 to the left. so, if i type data in j5, hit enter, i want it to jump to f5.
 
Upvote 0
This should work
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.CountLarge > 1 Then Exit Sub
    If Not Intersect(Range("J1:J10"), Target) Is Nothing Then
    Target.Offset(, -4).Select
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,905
Messages
6,175,297
Members
452,633
Latest member
DougMo

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