edit offset

ndendrinos

Well-known Member
Joined
Jan 17, 2003
Messages
1,694
starting in column A this activates A:F on the same row.
Code:
Range(ActiveCell, ActiveCell.Offset(0, 5)).Activate
need to modify to activate ONLY columns A,D,E&F
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Jim: Lately I select (secretly) for every time I publish on this forum the word "select" I get heck for it.
Andrew your solution is correct but now I need to precede it with more.
That is: go up one row and three cells to the left.
so it will be the equivalent of:
Code:
from active cell go up one row and three cells to the left Range(ActiveCell, ActiveCell.Offset(0, 5)).Activate

Many thanks

Hold on all ... I think I can do this on my own ...
 
Upvote 0
Using the Macro Recorder..

Code:
Sub Macro2()
'
' Macro2 Macro
'

'
    ActiveCell.Range("A1,D1,E1,F1").Select
    ActiveCell.Offset(0, 5).Range("A1").Activate
    ActiveCell.Offset(0, -5).Range("A1").Activate
End Sub
 
Upvote 0
Jim: Lately I select (secretly) for every time I publish on this forum the word "select" I get heck for it so I don't, I guess I should have this time
.
Andrew your solution is correct but now I need to precede it with more.

That is: go up one row and three cells to the left.
so it will be the equivalent of:
Code:
from active cell go up one row and three cells to the left Range(ActiveCell, ActiveCell.Offset(0, 5)).Activate

This is what needs to be done:


.............A.............B................C..............D...............E...............F
1...........2............3.................4..............Apple.......$1.00.............
2..........................................................activecell
3
4
From active cell in row2 column D I need to go up to row1 and select A,D,E (that is 2,Apple,$1.00)

The code is not specific to any particular row.... should work on any given row
thank you
 
Upvote 0
Code:
Sub Macro2()
'
' Macro2 Macro
'

'
    
    ActiveCell.Offset(-1, -3).Range("A1").Activate
    ActiveCell.Range("A1,D1,E1").Select

End Sub
 
Upvote 0
Got it
Code:
Sub test2()

    ActiveCell.Offset(-1, -3).Range("A1").Activate
    ActiveCell.Range("A1,D1,E1,F1").Select
    ActiveCell.Offset(0, 5).Range("A1").Activate
    ActiveCell.Offset(0, -5).Range("A1").Activate
End Sub

Thank you both and please if there is an easier way let us all know
 
Upvote 0
Still Shorter (less lines of code)....

Code:
Sub Macro2()
    
    With ActiveCell
        .Offset(-1, -3).Range("A1").Range("A1,D1,E1,F1").Select
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,866
Members
452,948
Latest member
UsmanAli786

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