LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Copy sets of ranges

Assuming that your data is located in Sheet1 and ranges to
copy always start with the first range C1:?? and no ranges
are skipped, this code will copy all the ranges up to Range
("B2").Value.

Note: This code will overwrite previous values on Item ?
sheets.

BTW, This may not be the best way but it works. I'm not a
pro.

Hope this helps...


Sub test()
Dim rng As Range

'Enter ALL your columns here
Set rng = Worksheets("Sheet1").Range("A:A,J:J,M:M") _
..SpecialCells(xlCellTypeConstants)

k = 1
i = Worksheets("sheet1").Range("b2").Value
For j = 1 To i
rng.Areas(k).Copy _
Destination:=Worksheets("Item " & k).Range("c3")
k = k + 1
Next j



End Sub
-----Original Message-----
I need to copy different ranges of data to different
Worksheets. The data will always be in ranges C1:I?, the
next range will be J1:I?, so on. The # of ranges to copy
varies. Cell B2 shows how many ranges must be copied.
Here's what i have so far.

Dim lngLastRow As String
Dim shtActive As Worksheet
Dim myStartColumn, myEndColumn As String
lngLastRow = myDataSheet.UsedRange.Rows.Count
myStartColumn = 3
myEndColumn = myStartColumn + 7

For i = 1 To Range("b2").Value
Range("R[1]C[" & myStartColumn & "]:R[" & lngLastRow & "]C
[" & myEndColumn & "]").Select
Selection.Copy
Sheets("Item" & i & "").Select
Range("C1").Select
ActiveSheet.Paste

I'm gettin a :Run time error '1004' : Method 'Range' of
object'_Global'failed" error.

Please help.

.

 
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
How can I copy big ranges of cells without drag or copy/paste? Ricardo Julio Excel Discussion (Misc queries) 3 March 23rd 10 02:38 PM
how do i "link" two sets of named ranges des-sa[_2_] Excel Discussion (Misc queries) 2 February 10th 09 11:08 AM
how copy formula that contains ranges so ranges do not overlap Patty Excel Worksheet Functions 1 November 20th 08 04:15 PM
Excel graph 3 sets of data. 2 sets as lines 1 as column? AndyN Charts and Charting in Excel 2 July 11th 08 01:18 PM
countif with two sets of non consectutive ranges at the same time Gover Excel Worksheet Functions 8 September 15th 07 06:13 AM


All times are GMT +1. The time now is 07:57 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"