Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default Xpose twenty rows then the next twent etc.


Want to xpose a list of items in A to cells in B twenty at a time then the next twentyin B below the first etc.

Thanks,
Howard

Option Explicit

Sub SuperJoin()
Range("B1") = Join(Application.Transpose(Range(Range("A1"), _
Range("A" & Rows.Count).End(xlUp))), " , ") '" / ")
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default Xpose twenty rows then the next twent etc.

hi Howard,

Sub SuperJoin()
Dim i As Long, x As Long
For i = 1 To Range("A" & Rows.Count).End(xlUp) Step 20
x = x + 1
Range("B" & x) = Join(Application.Transpose(Range(Range("A" & i),
Range("A" & i + 19))), ",")
Next
End Sub

isabelle

Le 2013-09-04 22:22, Howard a écrit :

Want to xpose a list of items in A to cells in B twenty at a time then the next twentyin B below the first etc.

Thanks,
Howard

Option Explicit

Sub SuperJoin()
Range("B1") = Join(Application.Transpose(Range(Range("A1"), _
Range("A" & Rows.Count).End(xlUp))), " , ") '" / ")
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default Xpose twenty rows then the next twent etc.

sorry it was missing a space at the last argument of Join function

Sub SuperJoin()
Dim i As Long, x As Long
For i = 1 To Range("A" & Rows.Count).End(xlUp) Step 20
x = x + 1
Range("B" & x) = Join(Application.Transpose(Range(Range("A" & i),
Range("A" & i + 19))), " ,")
Next
End Sub

isabelle


Le 2013-09-04 23:28, isabelle a écrit :
hi Howard,

Sub SuperJoin()
Dim i As Long, x As Long
For i = 1 To Range("A" & Rows.Count).End(xlUp) Step 20
x = x + 1
Range("B" & x) = Join(Application.Transpose(Range(Range("A" & i),
Range("A" & i + 19))), ",")
Next
End Sub

isabelle

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default Xpose twenty rows then the next twent etc.

On Wednesday, September 4, 2013 8:52:58 PM UTC-7, isabelle wrote:
sorry it was missing a space at the last argument of Join function



Sub SuperJoin()

Dim i As Long, x As Long

For i = 1 To Range("A" & Rows.Count).End(xlUp) Step 20

x = x + 1

Range("B" & x) = Join(Application.Transpose(Range(Range("A" & i),

Range("A" & i + 19))), " ,")

Next

End Sub



isabelle



Very nice. Thank you isabelle.

Regards,
Howard
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default Xpose twenty rows then the next twent etc.

Hi isabelle,

My first response was to a test of 1 to 100 in col A.

Worked just fine, 1 to 100 - 5 rows, 1-20, 21-40, 41-60, 61-80, 81-100.

I did some more tests with these results which puzzle me.

10 to 109 - 5 rows ok and 1 row with 19 commas
100 to 199 - 5 rows ok and 5 rows of 19 commas
a1 to a100 Type mismatch error.

Regards,
Howard



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Xpose twenty rows then the next twent etc.

Hi Howrd,

Am Wed, 4 Sep 2013 21:39:35 -0700 (PDT) schrieb Howard:

10 to 109 - 5 rows ok and 1 row with 19 commas
100 to 199 - 5 rows ok and 5 rows of 19 commas
a1 to a100 Type mismatch error.


try:

Sub SuperJoin()
Dim i As Long, x As Long
For i = 1 To Range("A" & Rows.Count).End(xlUp).Row Step 20
x = x + 1
With WorksheetFunction
Range("B" & x) = Join(Application.Transpose(Range(Cells(i, 1), _
Cells(i + .Min(19, .CountA(Range(Cells(i, 1), _
Cells(i + 19, 1))) - 1), 1))), ",")
End With
Next
End Sub


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default Xpose twenty rows then the next twent etc.


try:



Sub SuperJoin()

Dim i As Long, x As Long

For i = 1 To Range("A" & Rows.Count).End(xlUp).Row Step 20

x = x + 1

With WorksheetFunction

Range("B" & x) = Join(Application.Transpose(Range(Cells(i, 1), _

Cells(i + .Min(19, .CountA(Range(Cells(i, 1), _

Cells(i + 19, 1))) - 1), 1))), ",")

End With

Next

End Sub





Regards

Claus B.



Hi Claus,

With:

10 to 109 - works fine.

a1 to a100 - works fine.

100 strings like these two - works fine.
MAE511363
XEL551995

With this
100 to 199 I get five Scientific Notations like this 1.00101102103104E+59

I be way stumped. I checked column B cell format and nothing is selected.
I tried this at the end

Columns("B:B").Select
Selection.NumberFormat = "General"

and it did not fix anything.

Regards,
Howard
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Xpose twenty rows then the next twent etc.

Hi Howard,

Am Wed, 4 Sep 2013 23:00:52 -0700 (PDT) schrieb Howard:

100 strings like these two - works fine.
MAE511363
XEL551995

With this
100 to 199 I get five Scientific Notations like this 1.00101102103104E+59


first, you don't need the MIN
The comma is the separator for the thousands and so you will get a very
great number. Try semicolon as separator if you have numbers in your
range:

Sub SuperJoin()
Dim i As Long, x As Long
For i = 1 To Range("A" & Rows.Count).End(xlUp).Row Step 20
x = x + 1
With WorksheetFunction
Range("B" & x) = Join(Application.Transpose( _
Range(Cells(i, 1), Cells(i + .CountA( _
Range(Cells(i, 1), Cells(i + 19, 1))) - 1, 1))), ";")
End With
Next
End Sub

or comma with a following space:

Sub SuperJoin()
Dim i As Long, x As Long
For i = 1 To Range("A" & Rows.Count).End(xlUp).Row Step 20
x = x + 1
With WorksheetFunction
Range("B" & x) = Join(Application.Transpose( _
Range(Cells(i, 1), Cells(i + .CountA( _
Range(Cells(i, 1), Cells(i + 19, 1))) - 1, 1))), ", ")
End With
Next
End Sub


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default Xpose twenty rows then the next twent etc.


first, you don't need the MIN

The comma is the separator for the thousands and so you will get a very

great number. Try semicolon as separator if you have numbers in your

range:



Sub SuperJoin()

Dim i As Long, x As Long

For i = 1 To Range("A" & Rows.Count).End(xlUp).Row Step 20

x = x + 1

With WorksheetFunction

Range("B" & x) = Join(Application.Transpose( _

Range(Cells(i, 1), Cells(i + .CountA( _

Range(Cells(i, 1), Cells(i + 19, 1))) - 1, 1))), ";")

End With

Next

End Sub



or comma with a following space:



Sub SuperJoin()

Dim i As Long, x As Long

For i = 1 To Range("A" & Rows.Count).End(xlUp).Row Step 20

x = x + 1

With WorksheetFunction

Range("B" & x) = Join(Application.Transpose( _

Range(Cells(i, 1), Cells(i + .CountA( _

Range(Cells(i, 1), Cells(i + 19, 1))) - 1, 1))), ", ")

End With

Next

End Sub





Regards

Claus B.



Thanks Claus, that cleared it up very nicely. All works excellent.

Regards,
Howard
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
120= rupees one hundred twenty only digit to text Excel Worksheet Functions 2 May 25th 10 06:46 AM
Patek Philippe Twenty~4 Watch, Best Wristwatch [email protected] Excel Discussion (Misc queries) 0 February 5th 09 03:57 AM
creating a table from twenty worksheets Zuzeppeddu Excel Programming 3 May 2nd 07 01:40 PM
how do i convert numbers (25) into words (Twenty Five Only) ... Abidhsz Excel Worksheet Functions 1 March 19th 07 02:02 PM
How do I convert number 123 to text One Hundred and Twenty Three? Vidyaji Excel Discussion (Misc queries) 1 September 6th 05 03:59 PM


All times are GMT +1. The time now is 06:26 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"