LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Copy value until next value

Hi,

I am trying to write a code that will copy the contents of a cell - a month
- into all subsequent empty cells, unless another month is encountered. I
then want this new month to be copied into subsequent empty cells, until
another month is encountered. And so on. This will occur in one column only.

Reason: I have a spreadsheet that varies in size and format apart from one
column. The column contains one reference only per month's worth of line
items that follow. The line items do not contain any reference to the month
that they relate to. I am trying to write a code that will copy the only
reference of the month into every row that contains a line item for that
month, and repeat this for however many months there may be.

This is what I have so far, but it does not work:

Sub Month_copy

Dim CURRPERIOD As String
Dim CELL As Range, RNG As Range
With ActiveSheet
Set RNG = .Range(.Range("A1:a10000"), .Range("A1:A10000").End(xlDown))
End With

For Each CELL In RNG
CURRPERIOD = ActiveCell.Value
If ActiveCell = "" Then
ActiveCell.Value = CURRPERIOD
Else
CURRPERIOD = ActiveCell.Value
End If
Next
End sub

What I am trying to say is if the cell is blank, paste in the current month
value and move onto the next. If it is not blank, it must be a month
reference, therefore copy this into the subsequent blank cells.

Thanks in advance for any help received. (Hope this makes sense)

Ewan.
 
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 and paste versus copy and insert copied cells Alana New Users to Excel 1 September 28th 07 08:58 PM
Copy/Paste how to avoid the copy of formula cells w/o calc values Dennis Excel Discussion (Misc queries) 10 March 2nd 06 10:47 PM
EXCEL FILE a copy/a copy/a copy ....filename ve New Users to Excel 1 September 29th 05 09:12 PM
Code to copy range vs Copy Entire Worksheet - can't figure it out Mike Taylor Excel Programming 1 April 15th 04 08:34 PM
How copy format, font, color and border without copy/paste? Michel[_3_] Excel Programming 1 November 5th 03 04:43 PM


All times are GMT +1. The time now is 03:35 AM.

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"