Macro Query

rajivsoni

Board Regular
Joined
May 5, 2006
Messages
133
hi..
i have recorded a macro wherein i need to copy paste some data in my database everyday.
now the problem is tht the macro doesnot catch the last row.
for instance if i paste data today in A2:A10
tomorrow it should automatically paste data starting from A11.
the range of data tht i copy is not fixed.
This is a part of macro...
Range("A1").Select
Selection.End(xlDown).Select (This takes me to the last record on that row)
is there anyway i can copy the data in next column?

'Range("A11").Select (This will work only for the first time when i run the macro)

but if i use the same one tomorrow
Range("A1").Select
Selection.End(xlDown).Select This will take me to the last record but..
it will again go to
'Range("A11").Select
and then paste records there :(
can somebody help me with this ??
very very urgent for me...
Thanks in advance.

rajiv.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I suggest use countA formula to 'catch' the number of rows.
then assign a variable to countA(A:A)

use a empty cell ("Z1")?
say countA is 20,
count= range("Z1")

then change
'Range("A11").Select
 
Last edited:
Upvote 0
Sorry for posting so many times, I was busy in and out.
assuming you are not using cell Z1.

Code:
range("z1") = "=CountA(A:A)" '>>>>> change to a empty cell you don't use
count=range("Z1") '
Range("A1:A" & Count & " ").Select
range("z1")="" 'remove
 
Upvote 0
Doesnt help

This is the command i use

Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("Sales.xls").Activate
Sheets("Sales").Select
Range("A2").Select
Selection.End(xlDown).Select
I want to Paste the data after the LAST ROW.
if the Last row ends at A11, it should paste the data from A12 till A20 or whatever amount of data ive copied.
Somebody pleeeeeeeeez help meeeeeeeeeeeeee... :)
 
Upvote 0
Does this do what you want? Select the range then run the macro:

Code:
Sub test()
Dim NR As Long
NR = Workbooks("Sales").Sheets("Sales").Range("A" & Rows.Count).End(xlUp).Row + 1
Selection.Copy Destination:=Workbooks("Sales").Sheets("Sales").Range("A" & NR)
Application.CutCopyMode = False
End Sub
 
Upvote 0
Dint help...

But this line of code... did the trick...! :)
Workbooks("Daily Sales").Sheets("Sales").Range("A" & Rows.Count).End(xlUp).Row + 1

Thank you very much!!! :)
Life saver!! :)
 
Upvote 0

Forum statistics

Threads
1,214,861
Messages
6,121,973
Members
449,059
Latest member
oculus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top