Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default copy text of cells down to blank cells

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default copy text of cells down to blank cells

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default copy text of cells down to blank cells

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" wrote in message
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default copy text of cells down to blank cells

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
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
Count blank cells and cells with text rk0909 Excel Discussion (Misc queries) 3 May 2nd 08 03:56 AM
Formula Help: Add cells with certain text + cells that are blank Nicole L. Excel Worksheet Functions 3 February 27th 07 06:59 AM
how can we copy cells comments text and paste to cells שי פלד Excel Discussion (Misc queries) 3 December 12th 05 05:16 AM
copy blank cells Vicneswari Murugan Excel Discussion (Misc queries) 1 December 1st 04 02:12 PM
copy blank cells Vicneswari Murugan Excel Discussion (Misc queries) 0 December 1st 04 03:33 AM


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