ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Return to column A (https://www.excelbanter.com/excel-programming/333725-return-column.html)

richardlups

Return to column A
 

I have a macro which adds a new row above the current row and using
relative offset copies appropriate formulae and formatting.
Its success relies on starting from column A
How can I ensure the selected cell moves to column A before i run the
rest of the code
Thanks for your help


--
richardlups
------------------------------------------------------------------------
richardlups's Profile: http://www.excelforum.com/member.php...o&userid=24946
View this thread: http://www.excelforum.com/showthread...hreadid=384820


dominicb[_55_]

Return to column A
 

Good morning Richardlups

Not sure if you want to start from the whole of column A being selected
or just a single cell in column A being selected. I would suspect the
latter, so the line to use is as simple as:

Range("A1").Select

(but if you need to select the whole of column A use:
Columns("A:A").Select).

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=384820


richardlups[_2_]

Return to column A
 

Thanks for that
Unfortunately this takes me to cell A1 which is no good for the late
positioning
see code below

The purpose is to be able to add a new row anywhere in the worksheet
but I cant rely on the user to start from column A, just the row belo
where they want the new line.

ActiveSheet.Unprotect
Selection.EntireRow.Insert
ActiveCell.Offset(-1, 5).Range("A1").Select
Selection.Copy
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(-1, 3).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(-1, 2).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Offset(0, -10).Range("A1").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True
Scenarios:=Tru

--
richardlup
-----------------------------------------------------------------------
richardlups's Profile: http://www.excelforum.com/member.php...fo&userid=2494
View this thread: http://www.excelforum.com/showthread.php?threadid=38482


dominicb[_56_]

Return to column A
 

Hi Richardlups

So if I understand you right, the user could be in, say, G81 and click
on your macro to add a row, but the macro needs to be started from
column A (ie A81). The two lines below will make the activecell of any
current row in column A.

num = (ActiveCell.Columns(ActiveCell.Columns.Count).Colu mn - 1) * -1
ActiveCell.Offset(columnOffset:=num).Activate

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=384820


richardlups[_3_]

Return to column A
 

Thanks folks I have an answer now ..

--
richardlup
-----------------------------------------------------------------------
richardlups's Profile: http://www.excelforum.com/member.php...fo&userid=2494
View this thread: http://www.excelforum.com/showthread.php?threadid=38482



All times are GMT +1. The time now is 02:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com