LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Rearrange numbers in a range

On Sunday, October 25, 2015 at 7:32:49 PM UTC-5, Bruno Campanini wrote:

I have the numbers 1,2,3,4,5,6 in the source range("b4:g4") and would like to
produce

1,2,3,4,5,6
2,3,4,5,6,1
3,4,5,6,1,2
4,5,6,1,2,3
5,6,1,2,3,4
6,1,2,3,4,5

Basically the code would take each number in the source range and place it in
the 6th column if it is between 1 and 10 inclusive. First it would have to
the count how many numbers in the source range "b4:g4" are equal to and less
than 10. In this case the 6 numbers are less than 10 so it would produce 6
results. if it was 5 numbers that are less than 10 then it would produce 5
results. If all the numbers are more than 10 then no action is required.

The numbers in the source range can be in any order not necessarily in
sequence.

Any help would be greatly appreciated.
Thank you


Try this:
================================
Public Sub ShiftLeft()
Dim A, B, C, R, i, j
Dim Separator As String

R = [F2!B4:G4]
Separator = ","

For Each i In R
A = A & i & Separator
Next
A = Left(A, Len(A) - 1)

MsgBox A
For j = 1 To 5
B = Split(A, Separator, -1, 1)
For i = 1 To 5
C = C & B(i) & Separator
Next
C = C & B(0)
MsgBox C
A = C
C = NullString
Next

End Sub
==============================

Bruno


Very close. No result should have a value of more than 10 1n the rightmost column. Thank you
 
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
How to select top six numbers from a of range of random numbers Jack M Taylor Excel Worksheet Functions 4 January 30th 07 09:18 PM
Rearrange numbers from a column in a different order in a second c Gaetan58 Excel Discussion (Misc queries) 14 November 21st 06 07:43 AM
two columns range of numbers need to list all numbers in the range arsovat New Users to Excel 2 October 30th 06 08:21 PM
macro to rearrange numbers in cell? jim Excel Programming 4 May 31st 06 11:21 PM
Count comma separated numbers, numbers in a range with dash, not t Mahendra Excel Discussion (Misc queries) 0 August 8th 05 05:56 PM


All times are GMT +1. The time now is 11:54 PM.

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

About Us

"It's about Microsoft Excel"