Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default copy down to a certain row

I have a workbook with 2 sheets, the purpose of which is to take data from a
seperate file and configure it to enable it to be exported.

Sheet one is "Data" which the user copies data into from the other file, the
length (number of rows) changes each time data is copied in.
Sheet two "SDB" is basically a mapping sheet, the first row is column
headings and the second row has the data taken from "Data" e.g. =Data!AD2.

I want to create a macro to select row 2 and copy it down as many times as
there are rows in the "Data" sheet. I can count how many rows there are but I
can't figure out how to use this variable in the macro.

Thanks in advance,

Amy Homewood
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default copy down to a certain row

Row.Count is a constant to get the last row of the worksheet like 65536 for
Excel 2003. The code Below goes to AD65536 and the end method moves up the
worksheet until a Non-Empty cell is found.

LastRow = sheets("Data").Range("AD" & Rows.count).end(xlup).Row
set CopyRange = sheets("Data").Range("AD2:AD" & LastRow)
CopyRange.Copy Destination:=Sheets("Sheet1").Range("A1")


"AmyHomewood" wrote:

I have a workbook with 2 sheets, the purpose of which is to take data from a
seperate file and configure it to enable it to be exported.

Sheet one is "Data" which the user copies data into from the other file, the
length (number of rows) changes each time data is copied in.
Sheet two "SDB" is basically a mapping sheet, the first row is column
headings and the second row has the data taken from "Data" e.g. =Data!AD2.

I want to create a macro to select row 2 and copy it down as many times as
there are rows in the "Data" sheet. I can count how many rows there are but I
can't figure out how to use this variable in the macro.

Thanks in advance,

Amy Homewood

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default copy down to a certain row

Hi,

I've taken you literally when yo say the 'entire row' and suspect you may
not really mean that bit you should be able to adjust the ranges easilly
enough.

Sub copyDown()
lastrow = Sheets("Data").Cells(Cells.Rows.Count, "A").End(xlUp).Row
Sheets("SBD").range("A2:IV2").AutoFill Destination:=range("A2:IV" & lastrow)
End Sub

Mike

"AmyHomewood" wrote:

I have a workbook with 2 sheets, the purpose of which is to take data from a
seperate file and configure it to enable it to be exported.

Sheet one is "Data" which the user copies data into from the other file, the
length (number of rows) changes each time data is copied in.
Sheet two "SDB" is basically a mapping sheet, the first row is column
headings and the second row has the data taken from "Data" e.g. =Data!AD2.

I want to create a macro to select row 2 and copy it down as many times as
there are rows in the "Data" sheet. I can count how many rows there are but I
can't figure out how to use this variable in the macro.

Thanks in advance,

Amy Homewood

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default copy down to a certain row

Hi,

Thanks for the replies, just what I was looking for!

Amy

"Mike H" wrote:

Hi,

I've taken you literally when yo say the 'entire row' and suspect you may
not really mean that bit you should be able to adjust the ranges easilly
enough.

Sub copyDown()
lastrow = Sheets("Data").Cells(Cells.Rows.Count, "A").End(xlUp).Row
Sheets("SBD").range("A2:IV2").AutoFill Destination:=range("A2:IV" & lastrow)
End Sub

Mike

"AmyHomewood" wrote:

I have a workbook with 2 sheets, the purpose of which is to take data from a
seperate file and configure it to enable it to be exported.

Sheet one is "Data" which the user copies data into from the other file, the
length (number of rows) changes each time data is copied in.
Sheet two "SDB" is basically a mapping sheet, the first row is column
headings and the second row has the data taken from "Data" e.g. =Data!AD2.

I want to create a macro to select row 2 and copy it down as many times as
there are rows in the "Data" sheet. I can count how many rows there are but I
can't figure out how to use this variable in the macro.

Thanks in advance,

Amy Homewood

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
move or copy sheets doesn't copy format ColinX Excel Worksheet Functions 1 May 14th 08 10:07 PM
Copy and paste versus copy and insert copied cells Alana New Users to Excel 1 September 28th 07 08:58 PM
I copy a formula and the results copy from the original cell brooklynsd Excel Discussion (Misc queries) 1 June 23rd 07 01:35 AM
Copy/Paste how to avoid the copy of formula cells w/o calc values Dennis Excel Discussion (Misc queries) 10 March 2nd 06 10:47 PM
EXCEL FILE a copy/a copy/a copy ....filename ve New Users to Excel 1 September 29th 05 09:12 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"