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

I am trying to write a macro that will loop at blank lines. My issue i
I am dealing with 100+ addresses that may have 3-6 rows. I want t
transpose them so it is all on one row.

I have been using this when I know the number of rows. Unfortunately i
does not help when there are variable row numbers in the same sheet
But all the Addresses are seperated by blank lines... any help i
appreciated.



Sub Transpose1()

Dim d As Integer
Dim c As Integer

c = 1
d = 6

FinalRow = Range("A9999").End(xlUp).Row
For i = 1 To FinalRow

' Copy data columns, transpose and paste
Range("A" & c & ":A" & d).Copy
Range("B" & i & ":Z" & i).PasteSpecial Paste:=xlPasteAll
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True

d = d + 6
c = c + 6
Next i

Columns("A:A").Select
Selection.Delete Shift:=xlToLeft

Cells.Select
Cells.EntireColumn.AutoFit

ActiveWorkbook.Save


End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Looping at Blank Lines

Hi starfish900,

Try this, it might get you going,

'*****
Option Explicit
Sub test43978()
Dim firstRow As Long, lastRow As Long
Dim tRow As Long, firstCol As Integer
Dim rNum As Long, cCol As Integer

'enter starting position here
firstRow = 1
firstCol = 1

cCol = firstCol + 1
rNum = firstRow

Application.ScreenUpdating = False
With ActiveSheet
lastRow = .Cells(Rows.Count, firstCol).End(xlUp).Row
For tRow = firstRow To lastRow
If .Cells(tRow, firstCol) = "" Then
rNum = rNum + 1
cCol = firstCol + 1
GoTo nexttRow
End If
.Cells(rNum, cCol).Value = .Cells(tRow, firstCol).Value
.Cells(tRow, 1).Select
cCol = cCol + 1
nexttRow:
Next tRow
.Cells(firstRow, firstCol).EntireColumn.Delete
End With
Application.ScreenUpdating = True
End Sub
'*****

HTH
Anders Silven

"starfish900 " skrev i meddelandet
...
I am trying to write a macro that will loop at blank lines. My issue is
I am dealing with 100+ addresses that may have 3-6 rows. I want to
transpose them so it is all on one row.

I have been using this when I know the number of rows. Unfortunately it
does not help when there are variable row numbers in the same sheet.
But all the Addresses are seperated by blank lines... any help is
appreciated.



Sub Transpose1()

Dim d As Integer
Dim c As Integer

c = 1
d = 6

FinalRow = Range("A9999").End(xlUp).Row
For i = 1 To FinalRow

' Copy data columns, transpose and paste
Range("A" & c & ":A" & d).Copy
Range("B" & i & ":Z" & i).PasteSpecial Paste:=xlPasteAll,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True

d = d + 6
c = c + 6
Next i

Columns("A:A").Select
Selection.Delete Shift:=xlToLeft

Cells.Select
Cells.EntireColumn.AutoFit

ActiveWorkbook.Save


End Sub


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Looping at Blank Lines

Works Great!!!! Thanks much!


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Looping at Blank Lines

Glad to help, thanks for the feedback.

Anders Silven

"starfish900 " skrev i meddelandet
...
Works Great!!!! Thanks much!


---
Message posted from http://www.ExcelForum.com/


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
Macro not recognizing blank lines as blank pm Excel Discussion (Misc queries) 9 May 22nd 07 04:16 PM
Delete Blank Lines Charles Excel Discussion (Misc queries) 3 August 8th 05 05:11 PM
Looping Macro That adds a blank row between different part #'s fiero84 Excel Discussion (Misc queries) 5 March 25th 05 06:59 AM
Blank lines David O'brien Excel Programming 2 February 24th 04 06:21 PM
how to automatically insert blank lines in between non-blank lines No Name Excel Programming 2 November 17th 03 03:40 PM


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