Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default loop...until ..

Please help me with the following code:

Sub looprange()

x = ActiveCell.Row

y = ActiveCell.Column

'Have y start at column 2

y = 2

'Loop until a blank row is found

Do While Cells(y, 2).Value < ""

Column(y, 2).Value = Cells(x, 14).Value

'increase the value of x by 1 to act on the next row

x = x + 1

Loop


End Sub



Sources data as follows:

Column L Column M Column N Column O
Account Number Account Number Contract Date Contract Date
Account Number xxx-xxx-xxxx Contract Date 2001-02-19 12:00AM
Account Number xxx-xxx-xxxx Contract Date 2000-12-22 12:00AM
Account Number xxx-xxx-xxxx Contract Date 2001-05-28 12:00AM
Account Number xxx-xxx-xxxx Contract Date 2002-03-21 12:00AM
Account Number xxx-xxx-xxxx Contract Date 2002-05-22 12:00AM


What I need is that the heading in Column M " Account Number " will be
automatically pasted into the whole column L when I run Macro, and
column O heading " contact date " will does the same thing -- paste
into whole column N until it reach the blank cells, and so on.

Could somebody help me to fix the code which I did--it seems that it
doesn't work.

I would appreciate your help.

Yorson

  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default loop...until ..

Maybe this will help. Select cell in column M containing your header and run
the macro, repeat for column O.

Sub LoopRange()
With ActiveCell
Range(.Offset(0, -1), _
Cells(.End(xlDown).Row, .Column - 1)).Value = .Value
End With
End Sub


"Yorson" wrote:

Please help me with the following code:

Sub looprange()

x = ActiveCell.Row

y = ActiveCell.Column

'Have y start at column 2

y = 2

'Loop until a blank row is found

Do While Cells(y, 2).Value < ""

Column(y, 2).Value = Cells(x, 14).Value

'increase the value of x by 1 to act on the next row

x = x + 1

Loop


End Sub



Sources data as follows:

Column L Column M Column N Column O
Account Number Account Number Contract Date Contract Date
Account Number xxx-xxx-xxxx Contract Date 2001-02-19 12:00AM
Account Number xxx-xxx-xxxx Contract Date 2000-12-22 12:00AM
Account Number xxx-xxx-xxxx Contract Date 2001-05-28 12:00AM
Account Number xxx-xxx-xxxx Contract Date 2002-03-21 12:00AM
Account Number xxx-xxx-xxxx Contract Date 2002-05-22 12:00AM


What I need is that the heading in Column M " Account Number " will be
automatically pasted into the whole column L when I run Macro, and
column O heading " contact date " will does the same thing -- paste
into whole column N until it reach the blank cells, and so on.

Could somebody help me to fix the code which I did--it seems that it
doesn't work.

I would appreciate your help.

Yorson


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default loop...until ..

Perfect, I test it --it works!

Thanks JMB!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default loop...until ..

Hi, JMB

I have a new problem here, can you tell me how to insert the new column
when I perform the macro, for example, the column already filled with
the raw data, and I llike to ask macro to insert new column"L" ,
well... maybe you can modify the code for me.

Thanks again!

Yorson

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
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Loop Function unable to loop Junior728 Excel Programming 1 July 28th 05 10:23 AM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
How do I create a For loop within a For loop? Linking to specific cells in pivot table Excel Programming 2 January 24th 05 08:05 AM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


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