ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Receiving error 1004 - Method 'Rang' of object '_Global' failed (https://www.excelbanter.com/excel-programming/395365-receiving-error-1004-method-rang-object-_global-failed.html)

Tim

Receiving error 1004 - Method 'Rang' of object '_Global' failed
 
I am receiving error 1004 - Method 'Rang' of object '_Global' failed when
trying to select a single cell via Range.Select.
What is being done is cutting a range of cells and pasting to another place
of the same sheet.
Here is the line that I receive the error:
Range(Cells(row, NUM_OF_CELLS_TO_MOVE + 1)).Select.


Here is a copy of the code:
For row = 2 To lastRow
If currentStudentNumber < Cells(row, STUDENT_NUMBER_COL) Then
currentStudentNumber = Cells(row, STUDENT_NUMBER_COL).Value
currentStudent = row
sectionCount = 0
End If
If sectionCount < 0 Then
Range(Cells(row, TERM1COL), Cells(row, TERM1COL +
NUM_OF_CELLS_TO_MOVE)).Select
Selection.Cut
Range(Cells(row, NUM_OF_CELLS_TO_MOVE + 1)).Select
ActiveSheet.Paste
End If

sectionCount = sectionCount + 1

Next row

Thank you for any help.

Bob Phillips

Receiving error 1004 - Method 'Rang' of object '_Global' failed
 
Maybe just

Cells(row, NUM_OF_CELLS_TO_MOVE + 1).Select

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Tim" wrote in message
...
I am receiving error 1004 - Method 'Rang' of object '_Global' failed when
trying to select a single cell via Range.Select.
What is being done is cutting a range of cells and pasting to another
place
of the same sheet.
Here is the line that I receive the error:
Range(Cells(row, NUM_OF_CELLS_TO_MOVE + 1)).Select.


Here is a copy of the code:
For row = 2 To lastRow
If currentStudentNumber < Cells(row, STUDENT_NUMBER_COL) Then
currentStudentNumber = Cells(row, STUDENT_NUMBER_COL).Value
currentStudent = row
sectionCount = 0
End If
If sectionCount < 0 Then
Range(Cells(row, TERM1COL), Cells(row, TERM1COL +
NUM_OF_CELLS_TO_MOVE)).Select
Selection.Cut
Range(Cells(row, NUM_OF_CELLS_TO_MOVE + 1)).Select
ActiveSheet.Paste
End If

sectionCount = sectionCount + 1

Next row

Thank you for any help.




Tim

Receiving error 1004 - Method 'Rang' of object '_Global' faile
 
Bob,

Thank you, that is exactly what I needed.

"Bob Phillips" wrote:

Maybe just

Cells(row, NUM_OF_CELLS_TO_MOVE + 1).Select

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Tim" wrote in message
...
I am receiving error 1004 - Method 'Rang' of object '_Global' failed when
trying to select a single cell via Range.Select.
What is being done is cutting a range of cells and pasting to another
place
of the same sheet.
Here is the line that I receive the error:
Range(Cells(row, NUM_OF_CELLS_TO_MOVE + 1)).Select.


Here is a copy of the code:
For row = 2 To lastRow
If currentStudentNumber < Cells(row, STUDENT_NUMBER_COL) Then
currentStudentNumber = Cells(row, STUDENT_NUMBER_COL).Value
currentStudent = row
sectionCount = 0
End If
If sectionCount < 0 Then
Range(Cells(row, TERM1COL), Cells(row, TERM1COL +
NUM_OF_CELLS_TO_MOVE)).Select
Selection.Cut
Range(Cells(row, NUM_OF_CELLS_TO_MOVE + 1)).Select
ActiveSheet.Paste
End If

sectionCount = sectionCount + 1

Next row

Thank you for any help.






All times are GMT +1. The time now is 09:47 AM.

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