Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Establishing Rows to copy based on Offsets

I want to create a macro that selects specific rows off a data table
and copies the rows to a second data table. The rows are specified
based on the user's selection off a drop-down list. The user selects
a brand name from the drop-down and with an Offset function it
identifies the first row number associated with the selected brand,
and that number appears in cell b41, and the last row number for that
brand appears in cell c41. I am having difficulty taking these two
numbers and creating a statement that will select these rows (and all
those in between)copy them to another data table. So for my example I
select brand X and the corresponding rows of data associated with this
brand are 7:21.

Here's what I have:

Sub SelectProd()
sheets("list").select

Dim r1 as Range
Dim r2 as Range
set r1 = range("b41")
set r2 = range("c41")

Sheets("data").select
Rows(r1:r2).select

selection.copy
sheets("data2").select
range("A3").select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("A1").Select

End Sub

When I attempt this I get a 'Compile error' and 'Syntax error'
highlighting 'Rows(r1:r2).select'

I think I'm close but can't figure this out.

Appreciate any help/direction.

Thanks,

Tony B.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Establishing Rows to copy based on Offsets

Sub SelectProd()
Dim r1 as Integer
Dim r2 as Integer

r1 = Sheets("list").Range("b41").Value
r2 = Sheets("list").Range("c41").Value

Sheets("data").Activate
Rows(r1:r2).Copy Destination: = Sheets("data2").Range("A3")
Application.CutCopyMode = False
Range("A1").Select
End Sub

You were close!
Mike F
"Tony Bender" wrote in message
m...
I want to create a macro that selects specific rows off a data table
and copies the rows to a second data table. The rows are specified
based on the user's selection off a drop-down list. The user selects
a brand name from the drop-down and with an Offset function it
identifies the first row number associated with the selected brand,
and that number appears in cell b41, and the last row number for that
brand appears in cell c41. I am having difficulty taking these two
numbers and creating a statement that will select these rows (and all
those in between)copy them to another data table. So for my example I
select brand X and the corresponding rows of data associated with this
brand are 7:21.

Here's what I have:

Sub SelectProd()
sheets("list").select

Dim r1 as Range
Dim r2 as Range
set r1 = range("b41")
set r2 = range("c41")

Sheets("data").select
Rows(r1:r2).select

selection.copy
sheets("data2").select
range("A3").select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("A1").Select

End Sub

When I attempt this I get a 'Compile error' and 'Syntax error'
highlighting 'Rows(r1:r2).select'

I think I'm close but can't figure this out.

Appreciate any help/direction.

Thanks,

Tony B.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Establishing Rows to copy based on Offsets

Thanks Mike...
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
Copy rows based on parameters npop03 Excel Worksheet Functions 2 July 17th 09 03:52 PM
Automatically copy rows based on criteria Jay Excel Discussion (Misc queries) 5 November 9th 07 07:55 PM
Copy rows from one sheet to another based on a cell value SM1 Excel Worksheet Functions 1 December 21st 06 01:01 AM
Copy rows from one sheet to another based on a cell value SM1 New Users to Excel 1 December 21st 06 01:00 AM
Adding Rows offsets to working rows across two worksheets tom Setting up and Configuration of Excel 3 July 30th 06 07:54 PM


All times are GMT +1. The time now is 03:39 AM.

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"