Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy and paste versus copy and insert copied cells | New Users to Excel | |||
Copy/Paste how to avoid the copy of formula cells w/o calc values | Excel Discussion (Misc queries) | |||
EXCEL FILE a copy/a copy/a copy ....filename | New Users to Excel | |||
Code to copy range vs Copy Entire Worksheet - can't figure it out | Excel Programming | |||
How copy format, font, color and border without copy/paste? | Excel Programming |