Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Range

Status
Not open for further replies.

vickero007

IS-IT--Management
Apr 1, 2003
308
US
I have this Sub that I want to move the data two cells over to the left for 11 columns and 102 rows. I'm getting an error on the second Range "Argument not optional". What did I do wrong?

Private Sub Move()
Dim i As Integer
Dim j As Integer
With Worksheets("Sheet1").Range("I2")
For i = 0 To 102
For j = 0 To 11
Range.Offset(i, j).Value = (Range.Offset(0, 2).Value)
Next j
Next i
End Sub

-Volkoff007
 
Don't quite understand.... I think you have some syntax errors using the with and range... the code below will work but won't really accomplish anything useful, you'll just be setting a whole bunch of cells to the value of the cell 2 left of your range...

You will need to redefine your range each time, I think, but again I can't really be more specific because I don't understand what you are trying to do.

Code:
Private Sub Move()
    Dim i As Integer
    Dim j As Integer
    dim myRange as Range
    set myRange = Worksheets("Sheet1").Range("I2")
    For i = 0 To 102
        For j = 0 To 11
            myRange.Offset(i, j).Value = (myRange.Offset(0, 2).Value)
        Next j
    Next i
End Sub[\code]

Should work I think...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top