ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save cell location to a variable (https://www.excelbanter.com/excel-programming/433501-save-cell-location-variable.html)

Alberto Ast[_2_]

Save cell location to a variable
 
I need to save my active cell location into a variable so later I can select
a range from a specific cell all the way to the saved one cell.

For example I have data from A1:B20.. row 20 will change each time.
Then I do as follows:
Range ("A1:B1").select
Range(Selection, Selection.End(xlDown)).Select

Then I move one cell to the right
ActiveCell.Offset(0, 1).Select
I need to save this location (Cx)


Next I want to copy data from C1:G1 all the way to last record on column A
Range("C1:G1").Select
Selection.Copy

Here the tricky part
Range("C2:Cx).select
Paste

Hope is not too much detail for a simple question.
Thanks

Charabeuh[_4_]

Save cell location to a variable
 
Hello

you could declare a range variable

Dim Mycell as range

and replace
I need to save this location (Cx)

with
Set MyCell = ActiveCell


Then replace
Range("C2:Cx).select
with
Range("C2",MyCell).select



"Alberto Ast" a écrit dans le message
de ...
I need to save my active cell location into a variable so later I can
select
a range from a specific cell all the way to the saved one cell.

For example I have data from A1:B20.. row 20 will change each time.
Then I do as follows:
Range ("A1:B1").select
Range(Selection, Selection.End(xlDown)).Select

Then I move one cell to the right
ActiveCell.Offset(0, 1).Select
I need to save this location (Cx)


Next I want to copy data from C1:G1 all the way to last record on column A
Range("C1:G1").Select
Selection.Copy

Here the tricky part
Range("C2:Cx).select
Paste

Hope is not too much detail for a simple question.
Thanks



Alberto Ast[_2_]

Save cell location to a variable
 
This was great... thanks...

"Charabeuh" wrote:

Hello

you could declare a range variable

Dim Mycell as range

and replace
I need to save this location (Cx)

with
Set MyCell = ActiveCell


Then replace
Range("C2:Cx).select
with
Range("C2",MyCell).select



"Alberto Ast" a écrit dans le message
de ...
I need to save my active cell location into a variable so later I can
select
a range from a specific cell all the way to the saved one cell.

For example I have data from A1:B20.. row 20 will change each time.
Then I do as follows:
Range ("A1:B1").select
Range(Selection, Selection.End(xlDown)).Select

Then I move one cell to the right
ActiveCell.Offset(0, 1).Select
I need to save this location (Cx)


Next I want to copy data from C1:G1 all the way to last record on column A
Range("C1:G1").Select
Selection.Copy

Here the tricky part
Range("C2:Cx).select
Paste

Hope is not too much detail for a simple question.
Thanks




Charabeuh[_4_]

Save cell location to a variable
 
Thanks for the result

CA

"Alberto Ast" a écrit dans le message
de ...
This was great... thanks...

"Charabeuh" wrote:

Hello

you could declare a range variable

Dim Mycell as range

and replace
I need to save this location (Cx)

with
Set MyCell = ActiveCell


Then replace
Range("C2:Cx).select
with
Range("C2",MyCell).select



"Alberto Ast" a écrit dans le
message
de ...
I need to save my active cell location into a variable so later I can
select
a range from a specific cell all the way to the saved one cell.

For example I have data from A1:B20.. row 20 will change each time.
Then I do as follows:
Range ("A1:B1").select
Range(Selection, Selection.End(xlDown)).Select

Then I move one cell to the right
ActiveCell.Offset(0, 1).Select
I need to save this location (Cx)

Next I want to copy data from C1:G1 all the way to last record on
column A
Range("C1:G1").Select
Selection.Copy

Here the tricky part
Range("C2:Cx).select
Paste

Hope is not too much detail for a simple question.
Thanks






All times are GMT +1. The time now is 08:35 PM.

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