Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Copy to datasheet -Message for Ron De Bruin

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Copy to datasheet -Message for Ron De Bruin

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" wrote in message ...
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Copy to datasheet -Message for Ron De Bruin

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,F1 0,G11,F12:G12,F16:G16,F17:G17,F18:G18,F19:G19,F20: G20,F21:G21,F22:G22,F23:G23,F24:G24,F25:G25,F26:G2 6,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,O 33,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" wrote in message ...
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Copy to datasheet -Message for Ron De Bruin

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" wrote in message ...
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,F1 0,G11,F12:G12,F16:G16,F17:G17,F18:G18,F19:G19,F20: G20,F21:G21,F22:G22,F23:G23,F24:G24,F25:G25,F26:G2 6,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,O 33,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" wrote in message ...
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
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
Datasheet with drop down Trev[_2_] Excel Discussion (Misc queries) 0 October 28th 09 11:54 PM
Copy a Range from each workbook - Ron de Bruin VBA - a problem Philip[_2_] Excel Worksheet Functions 5 March 11th 07 06:07 AM
Ron de Bruin - Using PasteSpecial (xlPasteValues) instead of Copy Bob Excel Programming 8 August 16th 06 07:56 PM
PowerPoint datasheet KD[_3_] Excel Programming 0 June 22nd 04 11:54 AM
Message for Ron de Bruin Steph[_3_] Excel Programming 0 January 28th 04 07:59 PM


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