Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / August 2007

Tip: Looking for answers? Try searching our database.

Help with copy macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Crownman - 24 Aug 2007 20:44 GMT
Hi

I am trying to use the macro recorder in Excel 2003 to create a macro
that will copy selected data from one spreadsheet into another
spreadsheet.  The copy to spreadsheet is an Excel database and I need
the macro to find the first blank row in the database and then do the
copy.  My code so far is as follows:

Sub Copy_Feed_data()
'
' ' Keyboard Shortcut: Ctrl+m
'
   Sheets("FEED").Select
   Range("A2:M3").Select
   Selection.Copy
   Windows("ASCI PRICE DATABASE.xls").Activate
   ActiveWindow.WindowState = xlNormal
   ActiveWindow.SmallScroll Down:=-12
   Range("A6").Select
   Selection.End(xlDown).Select
   Range("A28").Select
   ActiveSheet.Paste
   ActiveWindow.WindowState = xlMinimized
End Sub

When I recorded the macro I used the end down keystrokes and then
keyed down one more row which was the first blank row when I recorded
the macro.  The marco interprets ths as selecting row 28 instead of
the first blank row.

Can someone help me with the correct command to get to the first blank
row instead of the specific row that was done when the macro was
recorded?

Thanks for any advice.

Crownman
Crownman - 24 Aug 2007 21:59 GMT
> Hi
>
[quoted text clipped - 33 lines]
>
> Crownman

I did a Google search and found the answer.

Selection.End(xlDown).Offset(1,0).Select

Crownman
Don Guillett - 24 Aug 2007 22:14 GMT
assumes both are open and you are in the source sheet.

Sub CopyToOpenSheet()
With Workbooks("destination.xls").Sheets("sheet1")
dlr = .Cells(Rows.Count, "a").End(xlUp).Row + 1
Sheets("source").Range("a2:m3").Copy .Cells(dlr, 1)
End With
End Sub

Signature

Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com

> Hi
>
[quoted text clipped - 33 lines]
>
> Crownman
Crownman - 24 Aug 2007 22:43 GMT
> assumes both are open and you are in the source sheet.
>
[quoted text clipped - 49 lines]
>
> - Show quoted text -

Thank you for your advice.

I intend to have the destination file open along with several source
files.  I then run the macro on each source file in sequence.  After I
added the offset reference and took out the line for A28, everything
worked perfectly.

Crownman
Don Guillett - 24 Aug 2007 22:57 GMT
If all source files are pretty much the same you could do this from the
desitination file without any selecting of files using the same theory I
gave you changed to stay in the destination file and copy from each source
file.

Signature

Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com

>> assumes both are open and you are in the source sheet.
>>
[quoted text clipped - 62 lines]
>
> Crownman
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.