ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Help Pls re macro cell address (https://www.excelbanter.com/excel-discussion-misc-queries/3092-help-pls-re-macro-cell-address.html)

Hugh Jago

Help Pls re macro cell address
 
I'm still having a problem with getting my macro to use a variable cell
address.
I'm trying to get the cursor to the cell two rows below my inported data,
and then cut and paste additional calculations. The data will vary in
length each time.

As an example if I start with Data from A2 to A6 then I need to go to A2,
count down, and in cell A8 I want to bring in additional calculations.
The next time I may have data from A2 to A2000, so the additional
calculations
will be pasted into A2002.
If I use the 'shift + ctrl' down arrow, when I enter data it sets the macro
with absolute adress. so the next time I use the macro the calculations are
in the wrong place.
Any ideas please with greatly appreciated.





JE McGimpsey

One way:

After importing your data, set a range object variable to the cell two
below the last filled cell:

Dim rDest As Range
Set rDest = Cells(Rows.Count, 1).End(xlUp).Offset(2, 0)

Then copy data to that range:

Sheets("Sheet1").Range("A1:J1").Copy Destination:=rDest

In article ,
"Hugh Jago" wrote:

I'm still having a problem with getting my macro to use a variable cell
address.
I'm trying to get the cursor to the cell two rows below my inported data,
and then cut and paste additional calculations. The data will vary in
length each time.

As an example if I start with Data from A2 to A6 then I need to go to A2,
count down, and in cell A8 I want to bring in additional calculations.
The next time I may have data from A2 to A2000, so the additional
calculations
will be pasted into A2002.
If I use the 'shift + ctrl' down arrow, when I enter data it sets the macro
with absolute adress. so the next time I use the macro the calculations are
in the wrong place.
Any ideas please with greatly appreciated.


Gord Dibben

Hugh

Selection.Copy Destination:= Sheets("Sheet2").Cells(Rows.Count, 1) _
.End(xlUp).Offset(2, 0)


Gord Dibben Excel MVP

On Wed, 5 Jan 2005 19:51:54 +0000 (UTC), "Hugh Jago" wrote:

I'm still having a problem with getting my macro to use a variable cell
address.
I'm trying to get the cursor to the cell two rows below my inported data,
and then cut and paste additional calculations. The data will vary in
length each time.

As an example if I start with Data from A2 to A6 then I need to go to A2,
count down, and in cell A8 I want to bring in additional calculations.
The next time I may have data from A2 to A2000, so the additional
calculations
will be pasted into A2002.
If I use the 'shift + ctrl' down arrow, when I enter data it sets the macro
with absolute adress. so the next time I use the macro the calculations are
in the wrong place.
Any ideas please with greatly appreciated.






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

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