Missing Data
The code I gave you searches for the month in row 1 so it doesn't matter in
what column the month is. HTH Otto
"Jeff Gross" wrote in message
...
What if the data for each month wa not actually next to each other. For
example, January = Column BB
February = Column BR
March = Column CH
April = Column CX
May = Column DN
June = Column ED
July = Column ET
August = Column FJ
September = Column FZ
October = Column GP
November = Column HF
December = Column HV
"Joel" wrote:
Try this code. I didn't know if the date in B5 was a serial date
(formated
as date) or a text string. code is shown as a serial date, but I
included a
commented line if it is really a string.
Sub completedata()
Lastcol = Cells(9, Columns.Count).End(xlToLeft).Column
Set MonthRange = Range("a9", Cells(9, Lastcol))
'get month name if it is date format
mname = Left(MonthName(Month(Range("B5"))), 3)
'uncomment line if month is string
mname = Range("B5")
Set c = MonthRange.Find(what:=mname, LookIn:=xlValues)
If c Is Nothing Then
MsgBox ("Can't find month " & mname)
Else
If c.Column < 1 Then
Lastrow = Cells(Rows.Count, c.Column).End(xlUp).Row
For RowCount = 10 To Lastrow
If Cells(RowCount, c.Column) = 0 Then
Cells(RowCount, c.Column) = Cells(RowCount, c.Column - 1)
End If
Next RowCount
Else
MsgBox ("Can't update Column A on worksheet")
End If
End If
End Sub
"Jeff Gross" wrote:
I need to write some code to look for missing data. Each month a
facility is
supposed to enter data for that month. I have to download a file which
has
this monthly data for several facilities compiled into one file. What
I need
the code to do is look at the date in a cell (B5) and then search the
document for the hours associated with that month. If a facility did
not
enter their data, then I need the code to copy the previous month's
hours
into the current months hours. For example:
B5 = Apr 07
A B C D
9 Jan Feb Mar Apr
10 200 299 104 0
11 400 400 333 233
12 200 300 900 100
13 233 444 555 0
I want to code to change the "0" in column D at row 10 to "104" and D13
from
"0" to "555".
Thanks.
Jeff
|