Sub RowRangeMove()
Sheets.Add().Name = "CopySheet"
With Sheets("BigDataSet - Copy")
.Range("A65000", .Range("A13000").End(xlUp)).Copy Destination:=Range("A1")
With Sheets("BigDataSet - Copy")
.Range("B65000", .Range("B13000").End(xlUp)).Copy Destination:=Range("B1")
With Sheets("BigDataSet - Copy")
.Range("C65000", .Range("C13000").End(xlUp)).Copy Destination:=Range("C1")
With Sheets("BigDataSet - Copy")
.Range("D65000", .Range("D13000").End(xlUp)).Copy Destination:=Range("D1")
With Sheets("BigDataSet - Copy")
.Range("E65000", .Range("E13000").End(xlUp)).Copy Destination:=Range("E1")
With Sheets("BigDataSet - Copy")
.Range("F65000", .Range("F13000").End(xlUp)).Copy Destination:=Range("F1")
With Sheets("BigDataSet - Copy")
.Range("G65000", .Range("G13000").End(xlUp)).Copy Destination:=Range("G1")
With Sheets("BigDataSet - Copy")
.Range("H65000", .Range("H13000").End(xlUp)).Copy Destination:=Range("H1")
With Sheets("BigDataSet - Copy")
.Range("I65000", .Range("I13000").End(xlUp)).Copy Destination:=Range("I1")
With Sheets("BigDataSet - Copy")
.Range("J65000", .Range("J13000").End(xlUp)).Copy Destination:=Range("J1")
End With
.
.
[iterate several times]
.
.
Sheets.Add().Name = "CopySheet7"
With Sheets("BigDataSet - Copy")
.Range("A455006", .Range("A502750").End(xlUp)).Copy Destination:=Range("A1")
With Sheets("BigDataSet - Copy")
.Range("B455006", .Range("B502750").End(xlUp)).Copy Destination:=Range("B1")
With Sheets("BigDataSet - Copy")
.Range("C455006", .Range("C502750").End(xlUp)).Copy Destination:=Range("C1")
With Sheets("BigDataSet - Copy")
.Range("D455006", .Range("D502750").End(xlUp)).Copy Destination:=Range("D1")
With Sheets("BigDataSet - Copy")
.Range("E455006", .Range("E502750").End(xlUp)).Copy Destination:=Range("E1")
With Sheets("BigDataSet - Copy")
.Range("F455006", .Range("F502750").End(xlUp)).Copy Destination:=Range("F1")
With Sheets("BigDataSet - Copy")
.Range("G455006", .Range("G502750").End(xlUp)).Copy Destination:=Range("G1")
With Sheets("BigDataSet - Copy")
.Range("H455006", .Range("H502750").End(xlUp)).Copy Destination:=Range("H1")
With Sheets("BigDataSet - Copy")
.Range("I455006", .Range("I502750").End(xlUp)).Copy Destination:=Range("I1")
With Sheets("BigDataSet - Copy")
.Range("J455006", .Range("J502750").End(xlUp)).Copy Destination:=Range("J1")
End With
End Sub
When I try to run this, I get an error saying “expecting End With”. The goal of the script is to copy ranges of rows and put them into new separate sheets (that I can then put into separate files that will read in Excel 2003 without exceeding the max number of rows). Should there be one or more additional End With statements somewhere in this?
Not only should there be at least one End With, there shouldn’t be so many With statements.
would be the correct syntax.
The With statement is simply a way to shorten up your lines of code. The With statement is a way of saying “I’m going to perform a bunch of actions on a specific object” and shorten up the individual lines of code.
Example:
Without the With statement, the code above would look like this:
In shorter terms, the With statement allows you to start out individual lines of code with a dot, and inside that with statement, the compiler will assume you mean the thing declared in your with statement.
So
is equivalient to