ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Script out of range (https://www.excelbanter.com/excel-programming/409217-script-out-range.html)

j

Script out of range
 
I am trying to correct a "script out of range" error in a macro, but I'm not
sure what it refers to. Here's a copy of the macro, if anyone could tell me
what I'm looking for that would be great. Thanks, J



Sub MoveRow2Data()
Dim X As Long, Z As Long
Dim LastColumn As Long
Const StartCol As Long = 9
Const GroupCount As Long = 5
Const MoveToColumn As Long = 4
Const DataRow As Long = 2
With Worksheets(TrustDepositCSVfile)
LastColumn = .Cells(DataRow, .Columns.Count).End(xlToLeft).Column
For X = StartCol To LastColumn Step 5
For Z = 0 To GroupCount - 1
..Cells(DataRow, X + Z).Copy _
Destination:=.Cells(X - 9 + DataRow + Z, MoveToColumn)
Next
Next
..Cells(DataRow, StartCol).Resize(1, LastColumn - _
StartCol + 1).ClearContents
End With
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

dan dungan

Script out of range
 
J

Which line of code shows the error?

Usually it means there is no data in the range.

Dan

dan dungan

Script out of range
 
J

Did you set a breakpoint?

Dan

j

Script out of range
 
Dan, the error doesn't refer to any particular line... and I'll re-check the
ranges... but it didn't highlight anything.. actually it didn't even open the
code page... J.



"dan dungan" wrote:

J

Which line of code shows the error?

Usually it means there is no data in the range.

Dan


Rick Rothstein \(MVP - VB\)[_1699_]

Script out of range
 
Is TrustDepositCSVfile a variable name or the actual name of your worksheet?
If the actual name of your worksheet, it needs to be in quote marks...

With Worksheets("TrustDepositCSVfile")

Rick


"J" wrote in message
...
I am trying to correct a "script out of range" error in a macro, but I'm
not
sure what it refers to. Here's a copy of the macro, if anyone could tell
me
what I'm looking for that would be great. Thanks, J



Sub MoveRow2Data()
Dim X As Long, Z As Long
Dim LastColumn As Long
Const StartCol As Long = 9
Const GroupCount As Long = 5
Const MoveToColumn As Long = 4
Const DataRow As Long = 2
With Worksheets(TrustDepositCSVfile)
LastColumn = .Cells(DataRow, .Columns.Count).End(xlToLeft).Column
For X = StartCol To LastColumn Step 5
For Z = 0 To GroupCount - 1
.Cells(DataRow, X + Z).Copy _
Destination:=.Cells(X - 9 + DataRow + Z, MoveToColumn)
Next
Next
.Cells(DataRow, StartCol).Resize(1, LastColumn - _
StartCol + 1).ClearContents
End With
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub



Mike H

Script out of range
 
try this

With Worksheets("TrustDepositCSVfile")

Mike

"J" wrote:

I am trying to correct a "script out of range" error in a macro, but I'm not
sure what it refers to. Here's a copy of the macro, if anyone could tell me
what I'm looking for that would be great. Thanks, J



Sub MoveRow2Data()
Dim X As Long, Z As Long
Dim LastColumn As Long
Const StartCol As Long = 9
Const GroupCount As Long = 5
Const MoveToColumn As Long = 4
Const DataRow As Long = 2
With Worksheets(TrustDepositCSVfile)
LastColumn = .Cells(DataRow, .Columns.Count).End(xlToLeft).Column
For X = StartCol To LastColumn Step 5
For Z = 0 To GroupCount - 1
.Cells(DataRow, X + Z).Copy _
Destination:=.Cells(X - 9 + DataRow + Z, MoveToColumn)
Next
Next
.Cells(DataRow, StartCol).Resize(1, LastColumn - _
StartCol + 1).ClearContents
End With
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub


j

Script out of range
 
Hi.. well i'm back again.. this glitch is more than I can figure out... The
macro seems to be putting the information in only "one" column...

the information that needs to be inserted is going down to the 5th row in
Column D and putting "all" of the information there, instead of placing each
row to the right of Column D. Does that make sense?

Thanks, J



"J" wrote:

Hi Everyone... well so far today I've reinstalled Windows XPSP2 PRO, updated
my drivers, reinstalled Office, ran a debug program, scanned the Registry and
then took all of your suggestions and advice, and guess what ....

It WORKS....!!!!!!!!!!!!!... YES...!!!!!!

There's a little glitch on the 4th row, but I'm going to try and figure that
out myself,,,

Thanks, very much for all your help and perseverance... now I'm going to
have a small drink and then carry on... Once again ... perfect... thanks,, J.

"Rick Rothstein (MVP - VB)" wrote:

Is TrustDepositCSVfile a variable name or the actual name of your worksheet?
If the actual name of your worksheet, it needs to be in quote marks...

With Worksheets("TrustDepositCSVfile")

Rick


"J" wrote in message
...
I am trying to correct a "script out of range" error in a macro, but I'm
not
sure what it refers to. Here's a copy of the macro, if anyone could tell
me
what I'm looking for that would be great. Thanks, J



Sub MoveRow2Data()
Dim X As Long, Z As Long
Dim LastColumn As Long
Const StartCol As Long = 9
Const GroupCount As Long = 5
Const MoveToColumn As Long = 4
Const DataRow As Long = 2
With Worksheets(TrustDepositCSVfile)
LastColumn = .Cells(DataRow, .Columns.Count).End(xlToLeft).Column
For X = StartCol To LastColumn Step 5
For Z = 0 To GroupCount - 1
.Cells(DataRow, X + Z).Copy _
Destination:=.Cells(X - 9 + DataRow + Z, MoveToColumn)
Next
Next
.Cells(DataRow, StartCol).Resize(1, LastColumn - _
StartCol + 1).ClearContents
End With
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub




Rick Rothstein \(MVP - VB\)[_1706_]

Script out of range
 
Okay, in looking back at your original message which prompted the code I
gave you, I may have missed the full intent of what you were asking back
then. In looking again, it now seems like you may have several rows of data
starting in I2 that you want to be moved (I read that you only had one row
of data that you wanted moved to D4). If you, in fact, have several rows of
data starting at I2 to be moved, then I'm guessing moving I2's data to D4
downward is correct; but where do you want I3's row of data moved to? If you
tell me that, I'm sure I can figure out what to do with the remaining rows
under it.

Rick


"J" wrote in message
...
Hi.. well i'm back again.. this glitch is more than I can figure out...
The
macro seems to be putting the information in only "one" column...

the information that needs to be inserted is going down to the 5th row in
Column D and putting "all" of the information there, instead of placing
each
row to the right of Column D. Does that make sense?

Thanks, J



"J" wrote:

Hi Everyone... well so far today I've reinstalled Windows XPSP2 PRO,
updated
my drivers, reinstalled Office, ran a debug program, scanned the Registry
and
then took all of your suggestions and advice, and guess what ....

It WORKS....!!!!!!!!!!!!!... YES...!!!!!!

There's a little glitch on the 4th row, but I'm going to try and figure
that
out myself,,,

Thanks, very much for all your help and perseverance... now I'm going to
have a small drink and then carry on... Once again ... perfect...
thanks,, J.

"Rick Rothstein (MVP - VB)" wrote:

Is TrustDepositCSVfile a variable name or the actual name of your
worksheet?
If the actual name of your worksheet, it needs to be in quote marks...

With Worksheets("TrustDepositCSVfile")

Rick


"J" wrote in message
...
I am trying to correct a "script out of range" error in a macro, but
I'm
not
sure what it refers to. Here's a copy of the macro, if anyone could
tell
me
what I'm looking for that would be great. Thanks, J



Sub MoveRow2Data()
Dim X As Long, Z As Long
Dim LastColumn As Long
Const StartCol As Long = 9
Const GroupCount As Long = 5
Const MoveToColumn As Long = 4
Const DataRow As Long = 2
With Worksheets(TrustDepositCSVfile)
LastColumn = .Cells(DataRow, .Columns.Count).End(xlToLeft).Column
For X = StartCol To LastColumn Step 5
For Z = 0 To GroupCount - 1
.Cells(DataRow, X + Z).Copy _
Destination:=.Cells(X - 9 + DataRow + Z, MoveToColumn)
Next
Next
.Cells(DataRow, StartCol).Resize(1, LastColumn - _
StartCol + 1).ClearContents
End With
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub





All times are GMT +1. The time now is 11:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com