Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Transposing hundreds of addresses in a column using VBA

Dear Experts:
I got hundreds of addresses in an excel sheet which need to be
transposed. The addresses are all in one column and arranged as
follows:

Name
Street
City
Tel
Blank row (1 to several)
Name Street
City
Tel
Blank row (1 to several)
etc. (another several hundred addresses more)

A macro should loop thru all these addresses and do the transposing
automatically. The addresses that are transposed should be placed
right next to each and every address.

Help is much appreciated. Thank you very much in advance. Regards,
Andreas
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Transposing hundreds of addresses in a column using VBA

Hi andreas
Try something like this?

Sub transposeAddress()
Application.ScreenUpdating = False
Dim SpaceCount As Integer
Dim TransposeRow As Integer
Dim Transpose As Range
SpaceCount = 0
TransposeCount = 0
Set TransposeCell = Range("C1") 'Select your own cell
Range("A1").Select 'Select your own cell
While SpaceCount < 10 ' select your value
If ActiveCell.Value = "" Then
ActiveCell.Offset(1, 0).Select
SpaceCount = SpaceCount + 1
Else
TransposeCell.Offset(TransposeCount, 0) = ActiveCell.Offset(0, 0)
TransposeCell.Offset(TransposeCount, 1) = ActiveCell.Offset(1, 0)
TransposeCell.Offset(TransposeCount, 2) = ActiveCell.Offset(2, 0)
TransposeCell.Offset(TransposeCount, 3) = ActiveCell.Offset(3, 0)
TransposeCount = TransposeCount + 1
SpaceCount = 0
ActiveCell.Offset(4, 0).Select
End If

Wend
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Transposing hundreds of addresses in a column using VBA

Try this code

Sub CombineRows()

LastRow = Range("A" & Rows.Count).End(xlUp).Row
'set rowcount to row where you want 1st entry
RowCount = 1
NewRow = RowCount
Start = False
Do While RowCount <= LastRow
If Start = False Then
If Range("A" & RowCount) < "" Then
Start = True
StartRow = RowCount
End If

Else
If Range("A" & (RowCount + 1)) = "" Then
ColCount = 1
For MoveRow = StartRow To RowCount
Cells(NewRow, ColCount) = Cells(MoveRow, "A")
ColCount = ColCount + 1
Next MoveRow
NewRow = NewRow + 1
Start = False
End If
End If
RowCount = RowCount + 1
Loop

Rows(NewRow & ":" & LastRow).Delete

End Sub


"andreas" wrote:

Dear Experts:
I got hundreds of addresses in an excel sheet which need to be
transposed. The addresses are all in one column and arranged as
follows:

Name
Street
City
Tel
Blank row (1 to several)
Name Street
City
Tel
Blank row (1 to several)
etc. (another several hundred addresses more)

A macro should loop thru all these addresses and do the transposing
automatically. The addresses that are transposed should be placed
right next to each and every address.

Help is much appreciated. Thank you very much in advance. Regards,
Andreas

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Transposing hundreds of addresses in a column using VBA


On Fri, 10 Jul 2009 02:11:25 -0700 (PDT), andreas
wrote:

Dear Experts:
I got hundreds of addresses in an excel sheet which need to be
transposed. The addresses are all in one column and arranged as
follows:

Name
Street
City
Tel
Blank row (1 to several)
Name Street
City
Tel
Blank row (1 to several)
etc. (another several hundred addresses more)

A macro should loop thru all these addresses and do the transposing
automatically. The addresses that are transposed should be placed
right next to each and every address.

Help is much appreciated. Thank you very much in advance. Regards,
Andreas


I don't know what you mean when you write

The addresses that are transposed should be placed
right next to each and every address.


But to transpose a column of address entries, that are located in, let us say,
A2:An, you could use this macro.

To enter this Macro (Sub), <alt-F11 opens the Visual Basic Editor.
Ensure your project is highlighted in the Project Explorer window.
Then, from the top menu, select Insert/Module and
paste the code below into the window that opens.

To use this Macro (Sub), <alt-F8 opens the macro dialog box. Select the macro
by name, and <RUN.

============================================
Option Explicit
Sub TranspAdr()
'Assumes every address group has at least two rows
'Does not test for this
Dim rSrc As Range, rDest As Range, c As Range
Dim i As Long

Set rSrc = Range("A2")
Set rDest = Range("B1")

i = 1
Do
Set rSrc = Range(rSrc, rSrc.End(xlDown))
rSrc.Copy
rDest(i, 1).PasteSpecial Transpose:=True
Application.CutCopyMode = False
Set rSrc = rSrc.End(xlDown).End(xlDown)
i = i + 1
Loop Until rSrc.End(xlDown).Row = Cells.Rows.Count
End Sub
=================================
--ron
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Transposing hundreds of addresses in a column using VBA

On 10 Jul., 12:56, Normek wrote:
Hi andreas
Try something like this?

Sub transposeAddress()
Application.ScreenUpdating = False
Dim SpaceCount As Integer
Dim TransposeRow As Integer
Dim Transpose As Range
SpaceCount = 0
TransposeCount = 0
Set TransposeCell = Range("C1") 'Select your own cell
Range("A1").Select * * * * *'Select your own cell
While SpaceCount < 10 ' select your value
* * If ActiveCell.Value = "" Then
* * * * *ActiveCell.Offset(1, 0).Select
* * * * *SpaceCount = SpaceCount + 1
* * Else
* * * * TransposeCell.Offset(TransposeCount, 0) = ActiveCell.Offset(0, 0)
* * * * TransposeCell.Offset(TransposeCount, 1) = ActiveCell.Offset(1, 0)
* * * * TransposeCell.Offset(TransposeCount, 2) = ActiveCell.Offset(2, 0)
* * * * TransposeCell.Offset(TransposeCount, 3) = ActiveCell.Offset(3, 0)
* * * * TransposeCount = TransposeCount + 1
* * * * SpaceCount = 0
* * * * ActiveCell.Offset(4, 0).Select
* * End If

*Wend
End Sub


Hi Normek,

that's it. Thank you very much for your professional help. Regards,
Andreas


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Transposing hundreds of addresses in a column using VBA

On 10 Jul., 12:56, Joel wrote:
Try this code

Sub CombineRows()

LastRow = Range("A" & Rows.Count).End(xlUp).Row
'set rowcount to row where you want 1st entry
RowCount = 1
NewRow = RowCount
Start = False
Do While RowCount <= LastRow
* *If Start = False Then
* * * If Range("A" & RowCount) < "" Then
* * * * *Start = True
* * * * *StartRow = RowCount
* * * End If

* *Else
* * * If Range("A" & (RowCount + 1)) = "" Then
* * * * *ColCount = 1
* * * * *For MoveRow = StartRow To RowCount
* * * * * * Cells(NewRow, ColCount) = Cells(MoveRow, "A")
* * * * * * ColCount = ColCount + 1
* * * * *Next MoveRow
* * * * *NewRow = NewRow + 1
* * * * *Start = False
* * * End If
* *End If
* *RowCount = RowCount + 1
Loop

Rows(NewRow & ":" & LastRow).Delete

End Sub



"andreas" wrote:
Dear Experts:
I got hundreds of addresses in an excel sheet which need to be
transposed. The addresses are all in one column and *arranged as
follows:


Name
Street
City
Tel
Blank row (1 to several)
Name Street
City
Tel
Blank row (1 to several)
etc. (another several hundred addresses more)


A macro should loop thru all these addresses and do the transposing
automatically. The addresses that are transposed should be placed
right next to each and every address.


Help is much appreciated. Thank you very much in advance. Regards,
Andreas- Zitierten Text ausblenden -


- Zitierten Text anzeigen -


Hi Joel,

it is working as desired. Thank you very much for your terrific help.
Regards, Andreas
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Transposing hundreds of addresses in a column using VBA

On 10 Jul., 13:51, Ron Rosenfeld wrote:
On Fri, 10 Jul 2009 02:11:25 -0700 (PDT), andreas
wrote:





Dear Experts:
I got hundreds of addresses in an excel sheet which need to be
transposed. The addresses are all in one column and *arranged as
follows:


Name
Street
City
Tel
Blank row (1 to several)
Name Street
City
Tel
Blank row (1 to several)
etc. (another several hundred addresses more)


A macro should loop thru all these addresses and do the transposing
automatically. The addresses that are transposed should be placed
right next to each and every address.


Help is much appreciated. Thank you very much in advance. Regards,
Andreas


I don't know what you mean when you write

The addresses that are transposed should be placed
right next to each and every address.


But to transpose a column of address entries, that are located in, let us say,
A2:An, you could use this macro.

To enter this Macro (Sub), <alt-F11 opens the Visual Basic Editor.
Ensure your project is highlighted in the Project Explorer window.
Then, from the top menu, select Insert/Module and
paste the code below into the window that opens.

To use this Macro (Sub), <alt-F8 opens the macro dialog box. Select the macro
by name, and <RUN.

============================================
Option Explicit
Sub TranspAdr()
'Assumes every address group has at least two rows
'Does not test for this
Dim rSrc As Range, rDest As Range, c As Range
Dim i As Long

Set rSrc = Range("A2")
Set rDest = Range("B1")

i = 1
Do
* * Set rSrc = Range(rSrc, rSrc.End(xlDown))
* * rSrc.Copy
* * rDest(i, 1).PasteSpecial Transpose:=True
* * Application.CutCopyMode = False
* * Set rSrc = rSrc.End(xlDown).End(xlDown)
* * i = i + 1
Loop Until rSrc.End(xlDown).Row = Cells.Rows.Count
End Sub
=================================
--ron- Zitierten Text ausblenden -

- Zitierten Text anzeigen -


Hi Ron,

did a couple of adjustments and now it is working as desired. Thank
you very much for your terrific help. Regards, Andreas
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Transposing hundreds of addresses in a column using VBA

On Fri, 10 Jul 2009 07:03:50 -0700 (PDT), andreas
wrote:

Hi Ron,

did a couple of adjustments and now it is working as desired. Thank
you very much for your terrific help. Regards, Andreas


Glad to help. Thanks for the feedback.
--ron
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
transposing postal addresses monika Excel Worksheet Functions 3 June 17th 08 10:53 PM
transposing addresses Mike G Excel Worksheet Functions 6 June 7th 07 10:04 PM
Transposing a row into a column Raj Excel Discussion (Misc queries) 4 July 25th 06 10:09 PM
Transposing addresses Big-D Excel Discussion (Misc queries) 1 August 4th 05 09:32 PM
Transposing one column into three Gilbert Excel Programming 11 November 10th 03 02:23 PM


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