How to move cell to LEFT?

Rampage598

New Member
Joined
Mar 11, 2022
Messages
23
Office Version
  1. 365
Platform
  1. Windows
Currently using this to move one cell to right:
ActiveCell.Offset(1, 0)

I am not getting how to move one cell to left....
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Just put a minus sign in-front of the 1 (assuming you are not in col A)
 
Upvote 0
That will move one cell down, NOT one cell to the right.

This would move one cell to the right:
VBA Code:
ActiveCell.Offset(0, 1)

This would move one cell to the left:
VBA Code:
ActiveCell.Offset(0, -1)

The format of OFFSET is:
Offset(row, column)
 
Upvote 0
That will move one cell down, NOT one cell to the right.

This would move one cell to the right:
VBA Code:
ActiveCell.Offset(0, 1)

This would move one cell to the left:
VBA Code:
ActiveCell.Offset(0, -1)

The format of OFFSET is:
Offset(row, column)
i tried with this.... but why data is writing on above that cell?
1647003494918.png
 
Upvote 0
That will move one cell down, NOT one cell to the right.

This would move one cell to the right:
VBA Code:
ActiveCell.Offset(0, 1)

This would move one cell to the left:
VBA Code:
ActiveCell.Offset(0, -1)

The format of OFFSET is:
Offset(row, column)
1647003529702.png

Expected Output
 
Upvote 0
Please post your ENTIRE code.
You have to be careful when using ActiveCell.
When things end going somewhere other than where you expect, it is usually because the ActiveCell isn't where you think it is when it hits that part of the code.
Very rarely do I ever use "ActiveCell" in my code (as you seldom ever need to use "Select" in your code).
 
Upvote 0
Please post your ENTIRE code.
You have to be careful when using ActiveCell.
When things end going somewhere other than where you expect, it is usually because the ActiveCell isn't where you think it is when it hits that part of the code.
Very rarely do I ever use "ActiveCell" in my code (as you seldom ever need to use "Select" in your code).
VBA Code:
Sub test1()
Sheets("FinalData").Select
lastCol = Split(Cells(2, Columns.Count).End(xlToLeft).Address, "$")(1)
Range("A2").Select
Selection.End(xlToRight).Select
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "Running"
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "Cycling"
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "Strength(Mins)"
ActiveCell.Offset(1, 0).Formula = "=Sumif($B$2:" & lastCol & "$2," ""*Strength(Mins)*""",B3:" & lastCol & "3)"
ActiveCell.Offset(0,-1).Formula = "=Sumif($B$2:" & lastCol & "$2," ""*Cycling*""",B3:" & lastCol & "3)"
End Sub
 
Upvote 0
Yep, you have way too many "ActiveCell" and "Select" statements in your code, which can make it very hard to determine exactly where you are at any point in time simply by looking at the code.
Since there is something obviously wrong with it (since it is not working the way you want it to), I do not want to try to "guess" what you are trying to do exactly (as I would be basing that guess on potentially flawed logic in the code).

What would be most helpful is for you to walk us through an example, explaining it step-by-step.
Start off by posting an example of what your data looks like to start, being sure to include the row/column headers, so we can see EXACTLY where your data resides.
Then walk us through a detailed explanation of exactly what you would like your code to do, and exactly where it should be placing these values/calculations.
 
Upvote 0
Yep, you have way too many "ActiveCell" and "Select" statements in your code, which can make it very hard to determine exactly where you are at any point in time simply by looking at the code.
Since there is something obviously wrong with it (since it is not working the way you want it to), I do not want to try to "guess" what you are trying to do exactly (as I would be basing that guess on potentially flawed logic in the code).

What would be most helpful is for you to walk us through an example, explaining it step-by-step.
Start off by posting an example of what your data looks like to start, being sure to include the row/column headers, so we can see EXACTLY where your data resides.
Then walk us through a detailed explanation of exactly what you would like your code to do, and exactly where it should be placing these values/calculations.
1647011760651.png
This is my excel file...........
after executing this code:
VBA Code:
Sub test1()
Sheets("FinalData").Select
lastCol = Split(Cells(2, Columns.Count).End(xlToLeft).Address, "$")(1)
Range("A2").Select
Selection.End(xlToRight).Select
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "Running"
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "Cycling"
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "Strength(Mins)"
ActiveCell.Offset(1, 0).Formula = "=Sumif($B$2:" & lastCol & "$2,""*Strength(Mins)*"",B3:" & lastCol & "3)"
ActiveCell.Offset(1, 0).Formula = "=Sumif($B$2:" & lastCol & "$2,""*Cycling*"",B3:" & lastCol & "3)"
ActiveCell.Offset(1, 0).Formula = "=Sumif($B$2:" & lastCol & "$2,""*Running*"",B3:" & lastCol & "3)"
End Sub

After running this code it will add 3 headers to right side of last column Running , cycling, Strength(mins)
1647012078013.png

Then first it will add formulas according to this sequence
1) Strength(Mins): ActiveCell.Offset(1, 0).Formula = "=Sumif($B$2:" & lastCol & "$2,""*Strength(Mins)*"",B3:" & lastCol & "3)"
2) Cycling: ActiveCell.Offset(1, 0).Formula = "=Sumif($B$2:" & lastCol & "$2,""*Cycling*"",B3:" & lastCol & "3)"
3) Running: ActiveCell.Offset(1, 0).Formula = "=Sumif($B$2:" & lastCol & "$2,""*Running*"",B3:" & lastCol & "3)"

1647012342121.png
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
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