ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save Cell address to activate it later in the procedure (https://www.excelbanter.com/excel-programming/418275-save-cell-address-activate-later-procedure.html)

loco

Save Cell address to activate it later in the procedure
 
I am writing a procedure where i am standing in a cell.
Thereafter i shall automatically in the prosedure change the width of column
D-E from 20 to 40.

Afterwards i want the same cell to be active as it was before i started the
procedure.

I am using relative reference in the procedure.

Can someone please help me with how i save an cell adrress for reuse later?

Don Guillett

Save Cell address to activate it later in the procedure
 
You do NOT have to goto columns d:e to set the column width
Sub widencolumn()
Columns("d:e").ColumnWidth = 40
End Sub

But, to answer your question
Sub goback()
returncell = ActiveCell.Address
Range("a33").Select
MsgBox ActiveCell.Address
Range(returncell).Select
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"loco" wrote in message
...
I am writing a procedure where i am standing in a cell.
Thereafter i shall automatically in the prosedure change the width of
column
D-E from 20 to 40.

Afterwards i want the same cell to be active as it was before i started
the
procedure.

I am using relative reference in the procedure.

Can someone please help me with how i save an cell adrress for reuse
later?



Bobt

Save Cell address to activate it later in the procedure
 
So, if I understand you code, you want to call a sub routine that takes care
of the column width piece then when it pops back to where you called the
procedure, you would like it to go back to the cell you started on. If
that's the case, simply do one one of the following:

(A) Create a string variable in the calling procedure and pass it the
address of the activecell.

(B) Create a Range variable and in the calling procedure pass it the
activecell.

Following your procedure call use the RANGE command to select your
variable's range.


"loco" wrote:

I am writing a procedure where i am standing in a cell.
Thereafter i shall automatically in the prosedure change the width of column
D-E from 20 to 40.

Afterwards i want the same cell to be active as it was before i started the
procedure.

I am using relative reference in the procedure.

Can someone please help me with how i save an cell adrress for reuse later?


loco

Save Cell address to activate it later in the procedure
 
Thank you very much.
I could copy your code suggestion directly into my VB-code and it did run OK
at once.

Loco

Don Guillett skrev:

You do NOT have to goto columns d:e to set the column width
Sub widencolumn()
Columns("d:e").ColumnWidth = 40
End Sub

But, to answer your question
Sub goback()
returncell = ActiveCell.Address
Range("a33").Select
MsgBox ActiveCell.Address
Range(returncell).Select
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"loco" wrote in message
...
I am writing a procedure where i am standing in a cell.
Thereafter i shall automatically in the prosedure change the width of
column
D-E from 20 to 40.

Afterwards i want the same cell to be active as it was before i started
the
procedure.

I am using relative reference in the procedure.

Can someone please help me with how i save an cell adrress for reuse
later?




Don Guillett

Save Cell address to activate it later in the procedure
 
Perhaps you should post the rest of your code for comments.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"loco" wrote in message
...
Thank you very much.
I could copy your code suggestion directly into my VB-code and it did run
OK
at once.

Loco

Don Guillett skrev:

You do NOT have to goto columns d:e to set the column width
Sub widencolumn()
Columns("d:e").ColumnWidth = 40
End Sub

But, to answer your question
Sub goback()
returncell = ActiveCell.Address
Range("a33").Select
MsgBox ActiveCell.Address
Range(returncell).Select
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"loco" wrote in message
...
I am writing a procedure where i am standing in a cell.
Thereafter i shall automatically in the prosedure change the width of
column
D-E from 20 to 40.

Afterwards i want the same cell to be active as it was before i started
the
procedure.

I am using relative reference in the procedure.

Can someone please help me with how i save an cell adrress for reuse
later?






All times are GMT +1. The time now is 05:06 AM.

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