Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Creating a range by going down a column until an empty cell is found

I'm trying to create records from column data with a macro that will build a
range in a column, from a starting cell, that will add the next cell down
until it finds an empty cell. Then it will do a transpose on that range.
From the last cell in the range, it will repeat the sequence until it
reaches 2 empty cells or the end of the column or worksheet.

Because the lengths of the column cells vary, I can't just use an offset.

Any ideas are welcome,

Jim

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Creating a range by going down a column until an empty cell is fou

I found this on the DG a while back:
Sub rearrange()

Dim curselection As Range
Dim i As Integer

Set curselection = Range("A1") 'or wherever you start

Do While curselection < ""

If Not curselection.Offset(1, 0) = "" Then
i = 1
Do
curselection.Offset(1, 0).Copy Destination:=curselection.Offset(0, i)
curselection.Offset(1, 0).EntireRow.Delete
i = i + 1
Loop Until curselection.Offset(1, 0) = ""
End If

curselection.Offset(1, 0).EntireRow.Delete
Set curselection = curselection.Offset(1, 0)

Loop

End Sub

HTH,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"JIm Samson" wrote:

I'm trying to create records from column data with a macro that will build a
range in a column, from a starting cell, that will add the next cell down
until it finds an empty cell. Then it will do a transpose on that range.
From the last cell in the range, it will repeat the sequence until it
reaches 2 empty cells or the end of the column or worksheet.

Because the lengths of the column cells vary, I can't just use an offset.

Any ideas are welcome,

Jim


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Creating a range by going down a column until an empty cell is fou

Ryan,
That was very helpful, I'm clicking Yes.
I just need to change the hardcoded cell A1 to whatever cell is active. It
shows me my original approach is wrnog and I still don't understand some
things but this will get the job done.
Thanks,
Jim

"ryguy7272" wrote in message
...
I found this on the DG a while back:
Sub rearrange()

Dim curselection As Range
Dim i As Integer

Set curselection = Range("A1") 'or wherever you start

Do While curselection < ""

If Not curselection.Offset(1, 0) = "" Then
i = 1
Do
curselection.Offset(1, 0).Copy Destination:=curselection.Offset(0, i)
curselection.Offset(1, 0).EntireRow.Delete
i = i + 1
Loop Until curselection.Offset(1, 0) = ""
End If

curselection.Offset(1, 0).EntireRow.Delete
Set curselection = curselection.Offset(1, 0)

Loop

End Sub

HTH,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"JIm Samson" wrote:

I'm trying to create records from column data with a macro that will
build a
range in a column, from a starting cell, that will add the next cell down
until it finds an empty cell. Then it will do a transpose on that range.
From the last cell in the range, it will repeat the sequence until it
reaches 2 empty cells or the end of the column or worksheet.

Because the lengths of the column cells vary, I can't just use an offset.

Any ideas are welcome,

Jim



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
find empty cells in a column then append row that empty cell is in vbnewbie Excel Programming 9 January 29th 09 09:27 AM
First Empty Cell in Found ROW Coza Excel Programming 2 March 21st 07 01:22 AM
determine the column where a cell was found usadream[_3_] Excel Programming 3 March 24th 06 01:55 PM
Finding next empty empty cell in a range of columns UncleBun Excel Programming 1 January 13th 06 11:22 PM
Help creating part of a macro (find Empty column) Jay[_17_] Excel Programming 2 May 27th 04 08:46 PM


All times are GMT +1. The time now is 01:51 PM.

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"