Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Looping thru columns

Seek assistance to convert the following macro code to loop the sorting from
col c thru col IV.
Range("A1:IR2000").Select
Selection.Copy
Application.Goto Reference:="R11000C1"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("C11001:C12999").Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("C11001"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("D11001:D12999").Select
Selection.Sort Key1:=Range("D11001"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

Thank you.
RobertR
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Looping thru columns

Not tested

Dim i As Long
Range("A1:IR2000").Copy
Range("A11000").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
For i = 3 To 256
Application.CutCopyMode = False
Cells(11001, i).Resize(1999).Sort Key1:=Range("C11001"), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Next i


--
HTH

Bob Phillips

"Robert" wrote in message
...
Seek assistance to convert the following macro code to loop the sorting

from
col c thru col IV.
Range("A1:IR2000").Select
Selection.Copy
Application.Goto Reference:="R11000C1"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("C11001:C12999").Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("C11001"), Order1:=xlAscending,

Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("D11001:D12999").Select
Selection.Sort Key1:=Range("D11001"), Order1:=xlAscending,

Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

Thank you.
RobertR



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Looping thru columns

Bob thanks for the speedy response. I get the following error msg.
"Run time error 1004

The Sort reference is not valid. Make sure that its within the
data you want to sort....."

Also do I end with "End Sub". Thanks.
--
Robert


"Bob Phillips" wrote:

Not tested

Dim i As Long
Range("A1:IR2000").Copy
Range("A11000").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
For i = 3 To 256
Application.CutCopyMode = False
Cells(11001, i).Resize(1999).Sort Key1:=Range("C11001"), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Next i


--
HTH

Bob Phillips

"Robert" wrote in message
...
Seek assistance to convert the following macro code to loop the sorting

from
col c thru col IV.
Range("A1:IR2000").Select
Selection.Copy
Application.Goto Reference:="R11000C1"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("C11001:C12999").Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("C11001"), Order1:=xlAscending,

Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("D11001:D12999").Select
Selection.Sort Key1:=Range("D11001"), Order1:=xlAscending,

Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

Thank you.
RobertR




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Looping thru columns

Sorry my mistake

Dim i As Long
Range("A1:IR2000").Copy
Range("A11000").PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
For i = 3 To 256
Application.CutCopyMode = False
Cells(11001, i).Resize(1999).Sort Key1:=Cells(11001,i), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Next i


--
HTH

Bob Phillips

"Robert" wrote in message
...
Bob thanks for the speedy response. I get the following error msg.
"Run time error 1004

The Sort reference is not valid. Make sure that its within the
data you want to sort....."

Also do I end with "End Sub". Thanks.
--
Robert


"Bob Phillips" wrote:

Not tested

Dim i As Long
Range("A1:IR2000").Copy
Range("A11000").PasteSpecial Paste:=xlPasteValues,

Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
For i = 3 To 256
Application.CutCopyMode = False
Cells(11001, i).Resize(1999).Sort Key1:=Range("C11001"), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Next i


--
HTH

Bob Phillips

"Robert" wrote in message
...
Seek assistance to convert the following macro code to loop the

sorting
from
col c thru col IV.
Range("A1:IR2000").Select
Selection.Copy
Application.Goto Reference:="R11000C1"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("C11001:C12999").Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("C11001"), Order1:=xlAscending,

Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,

_
DataOption1:=xlSortNormal
Range("D11001:D12999").Select
Selection.Sort Key1:=Range("D11001"), Order1:=xlAscending,

Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,

_
DataOption1:=xlSortNormal
End Sub

Thank you.
RobertR






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Looping thru columns

Bob, a BIG thank you for your help. My application runs in a jiffy compared to
using formulas for autosort which took ages.
--
RobertR





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Looping thru columns

You're welcome Robert. Always nice to get a result <G

Bob

"Robert" wrote in message
...
Bob, a BIG thank you for your help. My application runs in a jiffy

compared to
using formulas for autosort which took ages.
--
RobertR





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
looping through rows and columns mattguerilla Excel Discussion (Misc queries) 1 March 20th 07 05:14 PM
looping across columns in range? Amy Excel Discussion (Misc queries) 3 July 19th 05 08:01 PM
Looping through columns teresa Excel Programming 2 December 31st 04 07:25 PM
Looping thru columns beyond Z John Pierce Excel Programming 3 January 23rd 04 12:17 AM
Looping question for 2 columns [email protected] Excel Programming 1 October 24th 03 02:33 PM


All times are GMT +1. The time now is 10:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"