Save Cell address to activate it later in the procedure

  • Thread starter Thread starter loco
  • Start date Start date
L

loco

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?
 
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
 
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.
 
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:
 
Back
Top