H
havocdragon
Hi all,
I see alot on here about not using select and active or the like when
editing excel code for efficiency. So I am practicing on revising some code I
have, but I am running into a few problems.
Here is my code, my questions are below it.
Dim testrange As String
Dim SortRangeX As String
testrange = InputBox(prompt:="Enter Column Letter", Title:="Sort")
SortRangeX = testrange & ":" & testrange
Range("4:28").Copy
Sheets("Sort").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlFormulas
Application.CutCopyMode = False
Selection.Sort Key1:=Range(SortRangeX), Order1:=xlDescending
Selection.Copy
Sheets("Main Scorecard (All FSEs)").Select
Range("A4").Select
Selection.PasteSpecial Paste:=xlFormulas
Application.CutCopyMode = False
Now keep in mind, that this is copying from "Main Scorecard(All FSEs)" and
pasting to "Sort" sheet sorting and placing it back into the original sheet.
Here are some issues I have when revising it.
I could do
Range("4:28").Copy
Sheets.("Sort").Range("A1").paste special Paste:=XlFormulas
However the focus is still on the main sheet, and I cannot figure out how to
execute the sort on the sorting sheet without selecting it first.
Also, is there a way to get the range.copy and sheets.range.paste special
all in one line?
I see alot on here about not using select and active or the like when
editing excel code for efficiency. So I am practicing on revising some code I
have, but I am running into a few problems.
Here is my code, my questions are below it.
Dim testrange As String
Dim SortRangeX As String
testrange = InputBox(prompt:="Enter Column Letter", Title:="Sort")
SortRangeX = testrange & ":" & testrange
Range("4:28").Copy
Sheets("Sort").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlFormulas
Application.CutCopyMode = False
Selection.Sort Key1:=Range(SortRangeX), Order1:=xlDescending
Selection.Copy
Sheets("Main Scorecard (All FSEs)").Select
Range("A4").Select
Selection.PasteSpecial Paste:=xlFormulas
Application.CutCopyMode = False
Now keep in mind, that this is copying from "Main Scorecard(All FSEs)" and
pasting to "Sort" sheet sorting and placing it back into the original sheet.
Here are some issues I have when revising it.
I could do
Range("4:28").Copy
Sheets.("Sort").Range("A1").paste special Paste:=XlFormulas
However the focus is still on the main sheet, and I cannot figure out how to
execute the sort on the sorting sheet without selecting it first.
Also, is there a way to get the range.copy and sheets.range.paste special
all in one line?