PC Review


Reply
Thread Tools Rate Thread

copy text of cells down to blank cells

 
 
=?Utf-8?B?YW5kcmVzZzE5NzU=?=
Guest
Posts: n/a
 
      5th Oct 2006
how can i create a macro
let's say

column n

row2 al
row3
row4
row5 ps
row6
row7 ax
row8
row9

go to column "n", select first cell with text, copy that text to blank cells
below until it gets to another cell with text, copy that text to blank cells
below, and continue the same procedure until no more cells with text

result should be

row2 al
row3 al
row4 al
row5 ps
row6 ps
row7 ax
row8 ax
row9 ax

thanks a lot
 
Reply With Quote
 
 
 
 
acampbell012@yahoo.com
Guest
Posts: n/a
 
      5th Oct 2006
Modify ranges as needed:

Sub SameAsAbove()
'Copies data from cell above if current cell in range is blank
Dim MyRange As Range
Dim MyCell As Range
Dim Endrow As Integer
Endrow = Range("A65536").End(xlUp).Row
Set MyRange = Range("A1:G" & Endrow)
MyRange.Select
On Error Resume Next
For Each MyCell In MyRange
If MyCell.Value = "" Then
MyCell.Value = MyCell.Offset(-1, 0).Value
End If
Next MyCell
End Sub

andresg1975 wrote:
> how can i create a macro
> let's say
>
> column n
>
> row2 al
> row3
> row4
> row5 ps
> row6
> row7 ax
> row8
> row9
>
> go to column "n", select first cell with text, copy that text to blank cells
> below until it gets to another cell with text, copy that text to blank cells
> below, and continue the same procedure until no more cells with text
>
> result should be
>
> row2 al
> row3 al
> row4 al
> row5 ps
> row6 ps
> row7 ax
> row8 ax
> row9 ax
>
> thanks a lot


 
Reply With Quote
 
PCLIVE
Guest
Posts: n/a
 
      5th Oct 2006
This code should do what you want. this assumes that row 9 is your last
row. You can modify as appropriate.

Sub test()
Range("N2").Select
txt = ActiveCell.Value

Repeat:

If Range("N" & ActiveCell.Row + 1) = "" _
Then
LastRow = Range("N" & (ActiveCell.Row)).End(xlDown).Offset(-1,
0).Row
Range("N" & (ActiveCell.Row + 1) & ":N" & LastRow).Select

If Selection.End(xlDown).Row = 65536 _
Then
Range("N" & (ActiveCell.Row) & ":N9").Select
Selection.Value = txt
End
Else:
Selection.Value = txt
txt = Range("N" & LastRow + 1).Value
End If
Range(Selection.Address).End(xlDown).Select
Else:
End If
GoTo Repeat

End Sub


Regards

"andresg1975" <(E-Mail Removed)> wrote in message
news:02A8CC5E-9659-4F8A-8D1D-(E-Mail Removed)...
> how can i create a macro
> let's say
>
> column n
>
> row2 al
> row3
> row4
> row5 ps
> row6
> row7 ax
> row8
> row9
>
> go to column "n", select first cell with text, copy that text to blank
> cells
> below until it gets to another cell with text, copy that text to blank
> cells
> below, and continue the same procedure until no more cells with text
>
> result should be
>
> row2 al
> row3 al
> row4 al
> row5 ps
> row6 ps
> row7 ax
> row8 ax
> row9 ax
>
> thanks a lot



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      5th Oct 2006
Debra Dalgleish has some techniques:
http://www.contextures.com/xlDataEntry02.html


andresg1975 wrote:
>
> how can i create a macro
> let's say
>
> column n
>
> row2 al
> row3
> row4
> row5 ps
> row6
> row7 ax
> row8
> row9
>
> go to column "n", select first cell with text, copy that text to blank cells
> below until it gets to another cell with text, copy that text to blank cells
> below, and continue the same procedure until no more cells with text
>
> result should be
>
> row2 al
> row3 al
> row4 al
> row5 ps
> row6 ps
> row7 ax
> row8 ax
> row9 ax
>
> thanks a lot


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy an intial cells contents into the next series of blank cells ina column freeriderxlt Microsoft Excel Discussion 2 25th Aug 2009 07:47 AM
Count blank cells and cells with text rk0909 Microsoft Excel Misc 3 2nd May 2008 03:56 AM
Formula Help: Add cells with certain text + cells that are blank =?Utf-8?B?Tmljb2xlIEwu?= Microsoft Excel Worksheet Functions 3 27th Feb 2007 06:59 AM
Copy to first Blank cell in Colum C Non blank cells still exist be =?Utf-8?B?VWxyaWsgbG92ZXMgaG9yc2Vz?= Microsoft Excel Programming 2 8th Oct 2006 07:35 PM
how can we copy cells comments text and paste to cells =?Utf-8?B?16nXmSDXpNec15M=?= Microsoft Excel Misc 2 10th Dec 2005 03:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:57 PM.