PC Review


Reply
Thread Tools Rate Thread

Copy to datasheet -Message for Ron De Bruin

 
 
Tredown
Guest
Posts: n/a
 
      21st Jan 2008
I an using your copy next each other sub and last row function.
My question is there a maximum number of ranges that can be used within the
Set sourceRange = Sheets("Sheet1").Range statement. I have 41 ranges which
works fine but as soon as i add further ranges i get a run time error 1004.
If there is a maximum is there away to increase it.
Thanks in anticipation
Tredown
 
Reply With Quote
 
 
 
 
Ron de Bruin
Guest
Posts: n/a
 
      21st Jan 2008
Hi Tredown

Can you give me the link to the macro example you use now
We can find a solution for you then

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Tredown" <(E-Mail Removed)> wrote in message newsC3B0300-4E4E-4298-BAF0-(E-Mail Removed)...
>I an using your copy next each other sub and last row function.
> My question is there a maximum number of ranges that can be used within the
> Set sourceRange = Sheets("Sheet1").Range statement. I have 41 ranges which
> works fine but as soon as i add further ranges i get a run time error 1004.
> If there is a maximum is there away to increase it.
> Thanks in anticipation
> Tredown

 
Reply With Quote
 
Tredown
Guest
Posts: n/a
 
      23rd Jan 2008
Hi Ron
Thanks for replying, this the macro and function I am using
Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function


Sub Copy_Next_Each_Other()
Dim smallrng As Range, DestRange As Range
Dim DestSheet As Worksheet, Lr As Long
Dim SourceRange As Range, I As Integer

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'fill in the Source Sheet and range
Set SourceRange =
Sheets("Sheet1").Range("J3,F6:G6,F7:G7,F8:G8,F9,F10,G11,F12:G12,F16:G16,F17:G17,F18:G18,F19:G19,F20:G20,F21:G21,F22:G22,F23:G23,F24:G24,F25:G25,F26:G26,F27:G27,F28:G28,F29:G29,F32,F33:G33,F34:G34,F35:G35,F36:G36,F37:G37,N6:O6,N7:O7,N8,N9,N11,N12,N13,N14,N15,O16,O17,N18:O18")

'Fill in the destination sheet and call the LastRow
'function to find last row
Set DestSheet = Sheets("Data")
Lr = LastRow(DestSheet)
I = 1

For Each smallrng In SourceRange.Areas

'We make DestRange the same size as smallrng and use the
'Value property to give DestRange the same values
With smallrng
Set DestRange = DestSheet.Cells(Lr + 1, I) _
.Resize(.Rows.Count, .Columns.Count)
End With
DestRange.Value = smallrng.Value
I = I + smallrng.Columns.Count

Next smallrng

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Range("J3,D6:E14,G6:G8,G10:G14,D16:E30,G16:G30,D32:E37,G33:G37,L6:M9,O6:O7,L11:M15,O16:O21,L18:M30,O33,L35:L36,L40").Select
Selection.ClearContents
End Sub

regards
Tredown


"Ron de Bruin" wrote:

> Hi Tredown
>
> Can you give me the link to the macro example you use now
> We can find a solution for you then
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.nl/tips.htm
>
>
> "Tredown" <(E-Mail Removed)> wrote in message newsC3B0300-4E4E-4298-BAF0-(E-Mail Removed)...
> >I an using your copy next each other sub and last row function.
> > My question is there a maximum number of ranges that can be used within the
> > Set sourceRange = Sheets("Sheet1").Range statement. I have 41 ranges which
> > works fine but as soon as i add further ranges i get a run time error 1004.
> > If there is a maximum is there away to increase it.
> > Thanks in anticipation
> > Tredown

>

 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      23rd Jan 2008
Hi Tredown

One workaround of this limit you hit is to read the tip above the macro.
It is easer to maintain also then if you use so many areas of ranges

Tip: Use a row below your data with links to cells you want (=C3 in A50, =G15 in B50, …..).
You can hide this row if you want and copy a range like A50:Z50 for example with one of the
one area examples above

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Tredown" <(E-Mail Removed)> wrote in message news00D875D-6D8C-4F93-BDBD-(E-Mail Removed)...
> Hi Ron
> Thanks for replying, this the macro and function I am using
> Function LastRow(sh As Worksheet)
> On Error Resume Next
> LastRow = sh.Cells.Find(What:="*", _
> After:=sh.Range("A1"), _
> Lookat:=xlPart, _
> LookIn:=xlFormulas, _
> SearchOrder:=xlByRows, _
> SearchDirection:=xlPrevious, _
> MatchCase:=False).Row
> On Error GoTo 0
> End Function
>
>
> Sub Copy_Next_Each_Other()
> Dim smallrng As Range, DestRange As Range
> Dim DestSheet As Worksheet, Lr As Long
> Dim SourceRange As Range, I As Integer
>
> With Application
> .ScreenUpdating = False
> .EnableEvents = False
> End With
>
> 'fill in the Source Sheet and range
> Set SourceRange =
> Sheets("Sheet1").Range("J3,F6:G6,F7:G7,F8:G8,F9,F10,G11,F12:G12,F16:G16,F17:G17,F18:G18,F19:G19,F20:G20,F21:G21,F22:G22,F23:G23,F24:G24,F25:G25,F26:G26,F27:G27,F28:G28,F29:G29,F32,F33:G33,F34:G34,F35:G35,F36:G36,F37:G37,N6:O6,N7:O7,N8,N9,N11,N12,N13,N14,N15,O16,O17,N18:O18")
>
> 'Fill in the destination sheet and call the LastRow
> 'function to find last row
> Set DestSheet = Sheets("Data")
> Lr = LastRow(DestSheet)
> I = 1
>
> For Each smallrng In SourceRange.Areas
>
> 'We make DestRange the same size as smallrng and use the
> 'Value property to give DestRange the same values
> With smallrng
> Set DestRange = DestSheet.Cells(Lr + 1, I) _
> .Resize(.Rows.Count, .Columns.Count)
> End With
> DestRange.Value = smallrng.Value
> I = I + smallrng.Columns.Count
>
> Next smallrng
>
> With Application
> .ScreenUpdating = True
> .EnableEvents = True
> End With
> Range("J3,D6:E14,G6:G8,G10:G14,D16:E30,G16:G30,D32:E37,G33:G37,L6:M9,O6:O7,L11:M15,O16:O21,L18:M30,O33,L35:L36,L40").Select
> Selection.ClearContents
> End Sub
>
> regards
> Tredown
>
>
> "Ron de Bruin" wrote:
>
>> Hi Tredown
>>
>> Can you give me the link to the macro example you use now
>> We can find a solution for you then
>>
>> --
>>
>> Regards Ron de Bruin
>> http://www.rondebruin.nl/tips.htm
>>
>>
>> "Tredown" <(E-Mail Removed)> wrote in message newsC3B0300-4E4E-4298-BAF0-(E-Mail Removed)...
>> >I an using your copy next each other sub and last row function.
>> > My question is there a maximum number of ranges that can be used within the
>> > Set sourceRange = Sheets("Sheet1").Range statement. I have 41 ranges which
>> > works fine but as soon as i add further ranges i get a run time error 1004.
>> > If there is a maximum is there away to increase it.
>> > Thanks in anticipation
>> > Tredown

>>


 
Reply With Quote
 
Tredown
Guest
Posts: n/a
 
      23rd Jan 2008
Hi Ron
Thanks once again I will give that a try

Regards
Tredown

"Ron de Bruin" wrote:

> Hi Tredown
>
> One workaround of this limit you hit is to read the tip above the macro.
> It is easer to maintain also then if you use so many areas of ranges
>
> Tip: Use a row below your data with links to cells you want (=C3 in A50, =G15 in B50, …..).
> You can hide this row if you want and copy a range like A50:Z50 for example with one of the
> one area examples above
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.nl/tips.htm
>
>
> "Tredown" <(E-Mail Removed)> wrote in message news00D875D-6D8C-4F93-BDBD-(E-Mail Removed)...
> > Hi Ron
> > Thanks for replying, this the macro and function I am using
> > Function LastRow(sh As Worksheet)
> > On Error Resume Next
> > LastRow = sh.Cells.Find(What:="*", _
> > After:=sh.Range("A1"), _
> > Lookat:=xlPart, _
> > LookIn:=xlFormulas, _
> > SearchOrder:=xlByRows, _
> > SearchDirection:=xlPrevious, _
> > MatchCase:=False).Row
> > On Error GoTo 0
> > End Function
> >
> >
> > Sub Copy_Next_Each_Other()
> > Dim smallrng As Range, DestRange As Range
> > Dim DestSheet As Worksheet, Lr As Long
> > Dim SourceRange As Range, I As Integer
> >
> > With Application
> > .ScreenUpdating = False
> > .EnableEvents = False
> > End With
> >
> > 'fill in the Source Sheet and range
> > Set SourceRange =
> > Sheets("Sheet1").Range("J3,F6:G6,F7:G7,F8:G8,F9,F10,G11,F12:G12,F16:G16,F17:G17,F18:G18,F19:G19,F20:G20,F21:G21,F22:G22,F23:G23,F24:G24,F25:G25,F26:G26,F27:G27,F28:G28,F29:G29,F32,F33:G33,F34:G34,F35:G35,F36:G36,F37:G37,N6:O6,N7:O7,N8,N9,N11,N12,N13,N14,N15,O16,O17,N18:O18")
> >
> > 'Fill in the destination sheet and call the LastRow
> > 'function to find last row
> > Set DestSheet = Sheets("Data")
> > Lr = LastRow(DestSheet)
> > I = 1
> >
> > For Each smallrng In SourceRange.Areas
> >
> > 'We make DestRange the same size as smallrng and use the
> > 'Value property to give DestRange the same values
> > With smallrng
> > Set DestRange = DestSheet.Cells(Lr + 1, I) _
> > .Resize(.Rows.Count, .Columns.Count)
> > End With
> > DestRange.Value = smallrng.Value
> > I = I + smallrng.Columns.Count
> >
> > Next smallrng
> >
> > With Application
> > .ScreenUpdating = True
> > .EnableEvents = True
> > End With
> > Range("J3,D6:E14,G6:G8,G10:G14,D16:E30,G16:G30,D32:E37,G33:G37,L6:M9,O6:O7,L11:M15,O16:O21,L18:M30,O33,L35:L36,L40").Select
> > Selection.ClearContents
> > End Sub
> >
> > regards
> > Tredown
> >
> >
> > "Ron de Bruin" wrote:
> >
> >> Hi Tredown
> >>
> >> Can you give me the link to the macro example you use now
> >> We can find a solution for you then
> >>
> >> --
> >>
> >> Regards Ron de Bruin
> >> http://www.rondebruin.nl/tips.htm
> >>
> >>
> >> "Tredown" <(E-Mail Removed)> wrote in message newsC3B0300-4E4E-4298-BAF0-(E-Mail Removed)...
> >> >I an using your copy next each other sub and last row function.
> >> > My question is there a maximum number of ranges that can be used within the
> >> > Set sourceRange = Sheets("Sheet1").Range statement. I have 41 ranges which
> >> > works fine but as soon as i add further ranges i get a run time error 1004.
> >> > If there is a maximum is there away to increase it.
> >> > Thanks in anticipation
> >> > Tredown
> >>

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ron de Bruin's Copy to Worksheets marcia2026 Microsoft Excel Programming 2 4th Aug 2008 11:24 PM
Copy a Range from each workbook - Ron de Bruin VBA - a problem Philip Microsoft Excel Worksheet Functions 5 11th Mar 2007 06:07 AM
Ron de Bruin - Using PasteSpecial (xlPasteValues) instead of Copy =?Utf-8?B?Qm9i?= Microsoft Excel Programming 8 16th Aug 2006 07:56 PM
Ron de Bruin's Copy a range of each sheet nc Microsoft Excel Misc 6 1st Nov 2004 03:36 PM
Message for Ron de Bruin Steph Microsoft Excel Programming 1 28th Jan 2004 08:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:10 AM.