Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Macro To Copy Down

I want to copy data down a column in a ws until it finds
an existing text in the same column. It should then copy
that text down the same column until it finds the next
text entry and so on.
Would someone please help me with a macro or vb for this
task. I would be very grateful.

Hoping to hear from you soon.
JA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Macro To Copy Down

James,

The following code should do what you require.

If you have any queries let me know, I have tested it in
Excel 2002 and it works fine.

Yours sincerely,

Brent McIntyre

Create a CommandButton on the worksheet called
CommandButton_Process, then in VBA go to the worksheet you
put the button on and place the following code.

Public Sub CommandButton_Process_Click()

Dim Row_Count_Current As Long
Dim Row_Count_Final As Long
Dim Value_Current
Row_Count_Current = 1
Row_Count_Final = ActiveWorkbook.ActiveSheet.Cells
(Rows.Count, 1).End(xlUp).Row

While Row_Count_Current < Row_Count_Final + 1

If ActiveWorkbook.ActiveSheet.Range("A" &
Row_Count_Current) = "" Then

ActiveWorkbook.ActiveSheet.Range("A" &
Row_Count_Current) = Value_Current

Else

Value_Current =
ActiveWorkbook.ActiveSheet.Range("A" & Row_Count_Current)

End If

Row_Count_Current = Row_Count_Current + 1

Wend

End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Macro To Copy Down

Hi James,
For a Worksheet solution and a Macro solution see:

Replicate values into blank cells (#fill_empty)
Fill-Handle and Replication
http://www.mvps.org/dmcritchie/excel...htm#fill_empty

The macro bolds the original cells, but you can
remove line of code if you don't want it.
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Jamesa" wrote in message ...
I want to copy data down a column in a ws until it finds
an existing text in the same column. It should then copy
that text down the same column until it finds the next
text entry and so on.
Would someone please help me with a macro or vb for this
task. I would be very grateful.

Hoping to hear from you soon.
JA



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Macro To Copy Down

Jamesa, try

Sub CopyDown()
Const StartRowNo = 1
Const EndRowNo = 2000
Const ColumnNo = 1
Dim curText As String, curRowNo As Long

curRowNo = StartRowNo
Do While IsEmpty(Cells(curRowNo, ColumnNo)) And curRowNo <= EndRowNo
curRowNo = curRowNo + 1
Loop

Do While curRowNo <= EndRowNo
If IsEmpty(Cells(curRowNo, ColumnNo).Value) Then
Cells(curRowNo, ColumnNo).Value = curText
Else
curText = Cells(curRowNo, ColumnNo).Value
End If
curRowNo = curRowNo + 1
Loop
End Sub


Good luck

"Jamesa" wrote in message
...
I want to copy data down a column in a ws until it finds
an existing text in the same column. It should then copy
that text down the same column until it finds the next
text entry and so on.
Would someone please help me with a macro or vb for this
task. I would be very grateful.

Hoping to hear from you soon.
JA



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
Copy Macro robin Setting up and Configuration of Excel 1 January 19th 10 06:54 PM
Copy workbook, don't copy macro CongroGrey Excel Discussion (Misc queries) 1 June 13th 08 04:56 PM
Macro to copy pcor New Users to Excel 5 July 17th 07 01:06 PM
Copy a macro? Melissa Excel Discussion (Misc queries) 2 July 26th 06 08:32 PM


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